Rulepedia 196wiki https://196.miraheze.org/wiki/Main_Page MediaWiki 1.41.0 first-letter Media Special Talk User User talk Rulepedia Rulepedia talk File File talk MediaWiki MediaWiki talk Template Template talk Help Help talk Category Category talk Campaign Campaign talk Module Module talk Gadget Gadget talk Gadget definition Gadget definition talk Module:Buffer 828 43 90 2015-05-15T16:15:29Z wikipedia>Mr. Stradivarius 0 Protected Module:Buffer: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)) Scribunto text/plain --[[============================= This Module was written by Alexander Zhikun He, also known as, User:Codehydro on the English Wikipedia All methods were developed independently and any resemblance to other string buffer libraries would be coincidental. Furthermore, many methods will not work when compiled by standard Lua libraries as they depend on behaviors unique to the MediaMiki Scribunto mod, which, for example, has a getmetatable() method that always returns nil on non-tables. https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual Source code comments may be thin at some points because they are intended to be supplemented by the documentation page: https://en.wikipedia.org/wiki/Module:Buffer/doc Licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License https://en.wikipedia.org/wiki/Module:Buffer https://en.wikipedia.org/wiki/User:Codehydro =============================--]] local function Valid(v)--type validation if v and v~=true then--reject nil/boolean; faster than 2 type() comparisons local str = tostring(v)--functions not filtered since unlikely passed by accident (Scribunto does not have userdata/thread types) if str~=v and str=='table' then return rawget(v, 1) and table.concat(v) end--tostring(string-type) returns same ref; same refs compare faster than type() if str~='' then return str end--numbers are coerced to string per table.concat op; appending in string form saves ops on repeat concat end end local noOp, MBpairs = function()end do local iMap, vMap, oMap, pIter, pOther, pFast, Next--Map local function init()--init = noOp after first run function Next(t) return next, t end--slightly faster to do this than to use select() function pIter(t, k) k = (iMap[t] or MBpairs(t, true) and iMap[t])[not k and 1 or vMap[t][k]] return k, t[k] end--don't use rawget; accepting unmapped tables does not measurably affect performance. function pOther(t, k) k = (oMap[t] or MBpairs(t, true) and oMap[t])[nil==k and 1 or vMap[t][k]] return k, t[k] end--comparison to nil because false is a valid key function pFast(t, k) k = not k and 1 or k < (vMap[t] or #t) and k + 1 or nil return k, t[k] end--mapless iterator; almost as fast as native ipairs; slight performance penalty when length not cached --k and k < (vMap[t] or #t) and k + 1 or not k and 1 or nil return k, t[k] end--mapless iterator; almost as fast as native ipairs; slight performance penalty when length not cached local mk = {__mode = 'k'}--use mode 'k'; found that mode 'kv' sometimes garbage collects maps mid-loop (may not error because iterators auto re-map, but that's expensive) init, iMap, vMap, oMap = noOp, setmetatable({}, mk), setmetatable({}, mk), setmetatable({}, mk)--iMap is numeric keys, oMap is non-numeric keys, and vMap points to next key end function MBpairs(t, ...)--pairs always iterates in order local iter, ex = ... iter = iter==init()--nil if iter and not oMap[t] and ex==nil and rawget(t, 1)~=nil and next(t, #t)==nil then--while possible to miss keys, more thorough check would negate the benefit of pFast vMap[t] = #t return pFast, t, nil elseif ... or not vMap[t] or select('#', ...)~=1 then local ti, tn, to, n = {}, {}, {}, #t--reduces table lookups iMap[t], vMap[t], oMap[t] = ti, tn, to for k = 1, n do ti[k], tn[k] = k, k + 1 end--stage one avoids number type checking op in stage two for most numeric keys for k in (ex or Next)(t) do if not tn[k] then table.insert(tonumber(k)~=k and to or ti, k) end end if #ti~=n then table.sort(ti) for k = 1, #ti do tn[ti[k]] = k + 1 end--somewhat wasteful, but trying to avoid overwriting can be even more expensive end for k = 1, #to do tn[to[k]] = k + 1 end end return iter and pIter or oMap[t] and pOther or noOp, t--noOp for mapless end end local parent, rawkey, spec do--new scope for variables not reused outside (reduces number of var names that need to checked outside of scope) local mkv = {__mode='kv', __call=function(t,k,v)t[k]=v return k end}--shared meta for Buffer parent property, raw mode, and specialized functions parent, rawkey, spec = setmetatable({}, mkv), setmetatable({}, mkv), setmetatable({}, mkv)--shared meta less memory end local MB, MBi, MBmix, buffHTML, gfuncs, noCache, Element do--minimize number of locals per scope to reduce time spent sifting through irrelevant variable names local _stream do local stream--keep stream near top of scope local function init(f)--init = noOp after first run local function each(self, ...) for k = 1, select('#', ...) do k = Valid(select(k, ...))--slightly faster than table.insert(self, (Valid(select(k, ...)))) if k then table.insert(self, k) end end return self end init, stream, _stream = noOp, { __call = function(t, v) v = v and Valid(v) return v and table.insert(t, v) or t end,--last_concat cleared before entering stream mode __index = function(t, i) return i=='each' and each or MB.__index(t, i) and setmetatable(t, MB)[i] end,--no table look up minimizes resources to retrieve the only stream function __tostring = function(t) return setmetatable(t, MB)() end } for k, v in next, MB do stream[k] = stream[k] or v end setmetatable(stream, getmetatable(MB)) end function _stream(self, ...) self.last_concat = init() return setmetatable(self, stream):each(...) end end local function isMBfunc(Buffer, s, ...)--helper for :getParent()-like methods (including getBuffer which does not return a parent) return s and (select('#', ...)==0 and--eventually should figure out to make this work for :getHTML which is very similar (not rawkey[s] and tostring(s):match'^_.*' and MB.__index(Buffer, s) and MB.__index(Buffer, s)(Buffer) or MBmix(Buffer, s))--unprefixed function names append as a string or assert(MB.__index(Buffer, s), ('" %s " does not match any available Module:Buffer function'):format(s))(Buffer, ...)--getParent is a one-way trip so one-time assert not expensive ) or Buffer end local function MBselect(n, ...)--helper for :_out and :_str local n, seps = n - 1, {select(2, ...)} if type(seps[n])=='table' then if buffHTML and rawget(seps[n], buffHTML) then return ... end setmetatable(seps, {__index = setmetatable(seps[n], {__index = function(t) return rawget(t, 1) end})})[n] = nil end return ..., seps end local _inHTML do local lastBuffer, lastHTML local function init(...)--init replaced and new version called on return local create, mwFunc = mw.html.create do local mwHTMLmeta = getmetatable(create()) buffHTML, mwFunc, _inHTML = setmetatable(mw.clone(mwHTMLmeta), getmetatable(MB)), mwHTMLmeta.__index--buffHTML declared near top of module; remove _inHTML from outer scope function init(nodes, ...) local name, args, tag = select(... and type(...)=='table' and 1 or 2, nil, ...) tag = create(Valid(name), args) if nodes then table.insert(nodes, tag.parent and tag or rawset(tag, 'parent', parent[nodes])) end if args then local a, b = args.selfClosing, args.parent args.selfClosing, args.parent = nil if next(args) then Element._add(parent(tag.nodes, tag), args) end args.selfClosing, args.parent = a, b--in case args is reused end return tag end for k, v in next, {[mw] = mwHTMLmeta, __call = function(h, v) return MBmix(spec[h.nodes] and h.nodes or spec(setmetatable(parent(h.nodes, h), MB), Element), v) end, __concat = false,--false means take from MB __eq = false } do buffHTML[k] = v or MB[k] end end local nonSelf, BHi = {tag=true,done=true,allDone=true}, buffHTML.__index do local g g = {__index = function(t, i) if gfuncs and gfuncs[i] then g.__index, gfuncs = gfuncs return g.__index[i] end end} setmetatable(nonSelf, g) setmetatable(BHi, g) end for k in next, nonSelf do--any HTML objects returned by these funcs will be granted Module:Buffer enhancements local func = mwFunc[k] BHi[k] = function(t, ...) local HTML = func(t, ...) return parent[HTML] and HTML or setmetatable(parent(HTML, t), buffHTML) end end do local function joinNode(HTML, sep) local nodes, join = HTML.nodes if noCache and rawkey[sep] or Valid(sep) then join, HTML.nodes = tostring(rawset(HTML, 'nodes', {MB.__call(nodes, sep)})), nodes end return join or tostring(HTML) end for k, v in next, { getParent = function(HTML, ...) lastHTML = HTML return MBi.getParent(HTML:allDone(), ...) end,--return to Buffer that created the HTML tree getBuffer = function(HTML, ...) lastHTML = HTML return isMBfunc(lastBuffer, ...) end,--return to last used killParent = function(HTML, ...) MBi.killParent(HTML:allDone(), ...) return HTML end, _out = function(HTML, ...) if ...==0 then MBi._out(HTML.nodes, ...) return HTML end lastHTML, HTML = HTML, HTML:allDone() local n, ops, seps = select('#', ...) if n > 1 then local ops, seps = MBselect(n, ...) return parent[HTML]:_in(joinNode(HTML, rawget(seps, 0))):_out(ops, rawset(seps, buffHTML, true)) end return parent[HTML]:_(joinNode(HTML, ...)) end, _str = function(HTML, ...)--does not set lastHTML if ...==0 then return joinNode(HTML, select(2, ...)) end--passing 0 strings without calling allDone() local HTML, n = HTML:allDone(), select('#', ...) if n > 1 then local ops, seps = MBselect(n, ...) return parent[HTML]:_in(joinNode(HTML, rawget(seps, 1))):_str(ops, rawset(seps, buffHTML, true)) end return joinNode(HTML, ...) end, _parent = function(HTML, ...) table.insert(HTML.nodes, parent[HTML:allDone()]:_str(...)) return HTML end } do BHi[k] = v end end do local htmlArg, skip, outFuncs = {parent=true,selfClosing=true,tagName=true}, {} do local out local function func(nodes, ...) return out(parent[nodes], ...) end outFuncs = setmetatable({ tag = function(nodes, ...) return parent(setmetatable(init(nodes, ...), buffHTML), parent[nodes]) end, done = function(b, ops) b = parent[b] while b.parent and ops~=0 do b, ops = b.parent, ops and ops - 1 or 0 end return b end }, {__index = function(nodes, i) if rawget(BHi, i) then out = BHi[i] return func end--rawget to exclude globals end}) end Element = { _add = function(nodes, t) for k, v in MBpairs(t), t, skip[t] do (v~=true and MBmix or noOp)(nodes, v) end local HTML = parent[nodes] for k, v in MBpairs(t, false) do if htmlArg[k] then HTML[k] = v elseif v and v~=true then if nonSelf[k] then if k=='tag' then if type(v)=='table' then skip[v], k = 1, rawset(create(Valid(v[1])), 'parent', HTML) Element._add(spec(parent(k.nodes, k, table.insert(nodes, k)), Element), v) if k.selfClosing then k.nodes = nil else spec[k.nodes], parent[k.nodes] = nil end--free memory/reduce clutter; parent ref will auto-unset when k.nodes is nil if not k.tagName then k.styles, k.attributes = nil end else table.insert(nodes, create(v)) end elseif mwFunc[k] then if k=='done' and tonumber(v)~=v and v[1] and tonumber(v[1])==v[1] then skip[v] = 1 end MBmix(outFuncs[k](nodes, skip[v] and v[1]).nodes, v) elseif v[1] or v[2] then k = MBi[k](nodes, unpack(v, 1, rawset(skip, v, k=='_B' and 1 or 2)[v])) Element._add(getmetatable(k) and rawget(k, 'nodes') or k, v)--if k is not a table, then v should not contain any extra keys or this may error. else MBi[k](nodes, v) end--k probably == '_G' or '_R' elseif mwFunc[k] then if type(v)~='table' or rawget(v, 'nodes') then mwFunc[k](HTML, v) else local css = k=='css' for x, y in MBpairs(v, true) do (y and y~=true and mwFunc[k] or noOp)(HTML, css and x:gsub('_', '-') or x, y) end--iterate non-numbers first for _, y in MBpairs(v, nil) do (y and y~=true and mwFunc[k] or noOp)(HTML, y) end--don't bother with gsub since text must be quoted anyhow end elseif rawget(Element, k) or rawget(MBi, k) then if tonumber(v)==v or v[1]==nil or getmetatable(v) then (Element[k] or MBi[k])(nodes, v)--v is probably string-able object, or a table to be handled by :_all else (Element[k] or MBi[k])(nodes, unpack(v, 1, table.maxn(v))) end--v is definately a table else mwFunc.css(HTML, k:gsub('_', '-', 1), tostring(v)) end--oddly enough, :_add clocked its fastest runtime after adding auto-gsub as a feature skip[v] = nil end end return nodes end } local tempMeta = {mode='v', copy={styles=true,attributes=true}} function tempMeta.__index(t, i) return tempMeta.copy[i] and rawset(t, i, MBi._cc(false, 0, t.orig[i]))[i] or t.orig[i] end rawkey[setmetatable(Element, {__index = outFuncs, __concat=function(Element, v) return setmetatable({nodes=spec({}, Element),orig=parent[v]}, tempMeta) end})] = math.huge end function MBi:getHTML(...) lastBuffer = self if ... then if select('#', ...)==1 then return not rawkey[s] and tostring(...):match'^_' and BHi[...] and BHi[...](lastHTML) or lastHTML(...) else return assert(BHi[...], ('" %s " does not match any mw.html or Buffer-mw.html function'):format(tostring(...)))(lastHTML, select(2, ...)) end end return lastHTML end function MBi:_html(...) return MBi._(self, lastHTML, select(spec[self]==Element and select('#', ...)==0 and 1 or 2, true, ...)) end return init(...) end function _inHTML(self, ...) local HTML = init(nil, ...) if HTML.selfClosing and spec[self]==Element then self.last_concat = table.insert(self, HTML) return self end lastBuffer, lastHTML = self, setmetatable(parent(HTML, self), buffHTML)--set after 'args' table processed by :_add return HTML end end local _var, unbuild do local prev, rebuild local function init(...)--init replaced before return local function pick(b, v) return b and table.insert(b, v) or v end local function c(a, num) return rawset(a.a or a, 0, a[0] and a[0] + a.c or num and a[1] or a[1]:byte())[0] end local same, build, alt = {__tostring = function(a, b) return a.a[0] and pick(b, a.a.string and string.char(a.a[0]) or a.a.table and a.a[1][a.a[0]] or a.a[0]) end}, { __index = {c = 1}, __tostring = function(t) return t:_build() end, table = function(a, b) local i = next(a[1], a[0]) or a[0]==#a[1] and next(a[1]) return pick(b, rawset(a.a or a, 0, i)[1][i]) end,--change rate (a.c) ignored since users control the table's contents number = function(a, b) return pick(b, c(a, true)) end, string = function(a, b) return pick(b, string.char(c(a))) end }, {__index = function(a, i) return a.a[i] end, __tostring = function(a, b) return (rawget(a, 0) and a[0]==tostring(a[0]) and rawset(a, 0, a[0]:byte()) or a).a._build(a, b) end} local function shift(t, c) t[0] = t[0] and t[0] + c or t:_build() and t[0] - t.c + c if t.table then t[0] = (t[0] - 1) % #t[1] + 1 end end function rebuild(...) local v, c = ... if v or select('#', ...)==0 then if v and not c then return prev end local meta, c = select(v and 1 or 3, alt, c, same, 0) return setmetatable({a = prev, _build = meta.__tostring, c = c}, meta) elseif v==nil then--no-op elseif c then shift(prev, c)--v == false else prev:_build() end end init, noCache = function(v, c) prev = setmetatable({v, c = c, _build = build[type(v)] or v, [type(v)] = true, alt = {}}, build) return prev end, true return init(...) end function unbuild(sep) for k, v in MBpairs(sep, nil) do k = getmetatable(v) if k and (k==build or k==alt) then shift(v.a or v, -v.c) end end end function _var(self, ...) local obj if ... and ...~=true then obj = init(...) elseif prev then if ...~=false then obj = rebuild(...) else rebuild(...) end end return obj and MBi._(self, obj, nil, true) or self end end local lib; MBi = setmetatable({stream = _stream, _inHTML = _inHTML, _var = _var, _ = function(self, v, ...) local at, raw = select(select('#', ...)==1 and ...==true and 1 or 2, nil, ...) if raw then rawkey[self] = math.huge else v = Valid(v) end if v or raw then if at or rawkey[self] then raw = #self end--if length increases by more than one after table.insert, then set rawkey[self] = math.huge; rawkey[self] may be equal to a previous 'at' at, self.last_concat = at and (tonumber(at)~=at and raw + at or at) table.insert(self, select(at and 1 or 2, at, v)) if at and at < 0 or raw and #self - raw > 1 then rawkey[self] = math.huge elseif at and #self==raw then rawkey[self] = rawkey[self] and math.max(rawkey[self], at) or at end end--above line looks bizarre because one table.insert op may make length jump from 0 to 8: local wtf={[2]=2,[4]=4,[8]=8}mw.log(#wtf,table.insert(wtf,1),#wtf) return self end, _nil = function(self, at, ...) if ...~=true and ...~=false then--faster than type(...) ~= 'boolean' if not at or at=='0' then self[#self] = ... if ... then rawkey[self] = math.huge end else local n, v = tonumber(at), ... if n~=at then if n then n = #self + at elseif at~=true and select('#', ...)==0 then v, n = at, #self end end if n then if v==nil and n > 0 then table.remove(self, n) else self[math.floor(n)], rawkey[self] = v, math.huge end--floor position for consistency with Table library end end self.last_concat = nil end return self end, _all = function(self, t, valKey) for k, v in MBpairs(t) do MBmix(self, v, valKey) end for k, v in valKey and MBpairs(t, false) or noOp, t do if tonumber(v) then MBi._(self, k, v)--self not always a buffer elseif rawget(MBi, k) and v and v~=true then if v[1]==nil or getmetatable(v) then MBi[k](self, v) else MBi[k](self, unpack(v, 1, table.maxn(v))) end end end return self end, _str = function(t, ...) local n = select('#', ...) if n > 1 then local k, ops, seps, r = 2, MBselect(n, ...) r = MB(t(seps[1])) while parent[t] and ops > 1 and r:_(parent[t](seps[k]), 1) do t, k, ops = parent[t], k + 1, ops - 1 end return table.concat(r, seps[k] or nil) end return MB.__call(t, ...) end, _in = function (self, ...) return parent(MB(...), self) end, _out = function(t, ...) if ...==0 then return parent(t, parent[t], MBi._cc(t, t, MB.__call(t, (select(2, ...))), getmetatable(t))) end--love how :_cc needed nothing new to implement this *self pat on back* local n = select('#', ...) if n > 1 then local k, ops, seps = 1, MBselect(n, ...) while parent[t] and ops > 0 do t, k, ops = parent[t]:_(t(seps[k])), k + 1, ops - 1 end elseif parent[t] then return parent[t]:_(t(...)) end return t end, _cc = function(self, clear, copy, meta) if clear then if rawequal(clear, copy) then return self, spec[MBi._cc] and setmetatable(spec[MBi._cc], MB)--rawequal to avoid re-string via __eq in case both are different Buffer objects elseif copy==true then copy = self end if clear~=0 then assert(type(clear)=='table', debug.traceback('Buffer:_cc can only "clear" tables. Did you forget to call with a colon?', 2))--errors can be hard to trace without this for k in self and next or noOp, clear do rawset(clear, k, nil) end else return MBi._cc(false, {unpack(copy)}, copy) end--copy length w/o empty strings; recursion to avoid self = false causing garbage collection (non-weak child may exist) if self==false or copy and type(copy)=='table' then--self==false means copy is a table (saves a type op for recursive calls) meta = meta or getmetatable(copy) if self and #copy > 1 then--preserves length with empty strings; developed from studying http://www.lua.org/source/5.1/ltable.c.html local n, null, i, e = #copy, {}, math.ldexp(2, select(2, math.frexp(#copy)) - 2) e, spec[MBi._cc], parent[null] = i - 1, null, clear for k = 1, e do table.insert(clear, false) end while i<=n do table.insert(clear, i, '') i, null[i] = i + math.ldexp(2, select(2, math.frexp(n - i)) - 2), '' end for k = 1, e do rawset(clear, k, nil) end end for k, v in next, copy do rawset(clear, k, type(v)=='table' and MBi._cc(false, 0, v) or v) end elseif copy then rawset(clear, 1, (Valid(copy))) end rawkey[setmetatable(clear, meta)], parent[clear] = rawkey[copy], parent[copy] end return self and rawset(self, 'last_concat', nil) or clear end, _parent = function(self, ...) return parent[self] and MBi._(self, parent[self]:_str(...)) or self end, getParent = function(self, ...) return isMBfunc(parent[self] or parent[parent(self, setmetatable({}, MB))], ...) end, killParent = function(self, ...) return parent[self] and isMBfunc(parent[self], ...) and parent(self) or self end, _build = function(self, t) table.insert(t, self()) end,--for compatibility with mw.html:node() last_concat = false--prevent library check }, {__index = function(t, i)--import string, mw.text, and mw.ustring libraries on an as-needed basis local func = string[i] or mw.text[i] or mw.ustring[i] or type(i)=='string' and mw.ustring[i:match'^u(.+)'] if func then lib = lib or function (s, f, ...) if parent[s] and next(s)==nil then return s:_((f(tostring(parent[Element and (spec[s]==Element and s:allDone() or spec[parent[s]]==Element and parent[s]) or s]), ...))) end return f(tostring(s), ...)--not using ternary/logical operators here to allow multiple return values end return rawset(t, i, i:match'^u?gsub' and function(self, p, r, ...)return lib(self, func, p, r or '', ...)end--Why are ugsub/gsub special? because empty strings are against my religion! or function(self, ...)return lib(self, func, ...)end)[i] end end}) end function MBmix(t, v, ...) return v and ((type(v)~='table' or getmetatable(v)) and MBi._(t, v) or (select('#', ...)==0 and spec[t] and spec[t]._add or MBi._all)(t, v, ...)) or t end--:_all always passes two args local _G, new_G = _G--localize _G for console testing (console _G ~= module _G) return setmetatable({__index = function(t, i) return spec[t] and spec[t][i] or MBi[i] end, __call = function(t, ...) local rawsep, sep, i, j, raw = noCache and rawkey[...] and ..., ... if i or j or rawsep or Valid(sep) then raw, sep, i, j = rawkey[spec[t]] or rawkey[t], rawsep or Valid(sep), i and (i~=tonumber(i) and i + #t or i), j and (j~=tonumber(j) and j + #t or j) if rawsep or raw and (raw>=(j or #t) or i < 1) then raw, i, j = {}, i and math.floor(i), j and math.floor(j)--floor for consistency with table.concat(t, sep, i, j), which ignores decimals raw.lc, t.last_concat = t.last_concat--temporarily unset last_concat to prevent disqualification from mapless iteration for k, v in MBpairs(t) do if raw[1] or not i or k>=i then if j and k > j then break end if raw.s then raw.s = table.insert(raw, tostring(sep)) end--if sep contains v and v is a Buffer-variable, sep must be strung before v k = Valid(v) if k then raw.s = rawsep or sep and raw[1] and table.insert(raw, sep) table.insert(raw, k) end end end if rawsep and not raw.s then raw[#raw] = unbuild(sep) end--unbuild rawsep if final index in t was invalid t.last_concat = raw.lc return table.concat(raw) end return table.concat(t, sep, i and math.max(i, 1), j and math.min(j, #t)) end return MB.__tostring(t) end, __tostring = function(t) if t.last_concat then return t.last_concat end local r = rawkey[spec[t]] or rawkey[t] r = table.concat(r and r>=#t and MBi._all({}, t) or t) return (noCache or rawset(t, 'last_concat', r)) and r end, __concat = function(a, b) if buffHTML then for k = 1, 2 do local v = select(k, a, b)--faster than for k, v in pairs{a, b} do if v and spec[v] and spec[v]==Element then if parent[v].selfClosing then if rawequal(a, b) then return (not noCache or parent[v].tagName) and v:_str(0):rep(2) or v:_str(0)..v:_str(0) end--rawequal avoids premature tostring of Buffer:_var objects; b, a = select(k, b, parent[v], a) else local temp = Element .. v --helper method; returns a mirror of parent[v] MBmix(MBmix(parent(temp.nodes, temp), a), k==1 and spec[b]==Element and parent[b] or b) return buffHTML.__tostring(setmetatable(temp, {__index=parent[v], __mode='v'}))--switch from tempMeta to avoid MBi._cc op of styles/attributes end end end end return table.concat(MBmix(MBmix({}, a), b)) end, __pairs = MBpairs, __ipairs = MBpairs, __eq = function(a, b) return tostring(a)==tostring(b) end--avoid a==b in this module; use rawequal(a,b) when they may be different Buffers (premature tostring waste ops and is bad for Buffer:_var) }, {__tostring = function()return''end, __call = function(self, ...) MB = MB or self if new_G then if ... and _G and ...==_G then new_G = ... end elseif ... and (...==_G or type(...)=='table' and (...)._G==...) then local Nil, mG = {}, (...):getmetatable() or (...):setmetatable{}:getmetatable() new_G, _G, gfuncs = ..., ..., {--gfuncs stored for Buffer:_inHTML; new_G is a is a Module:Buffer local declared just before the final return statement. _G = function(self, i, ...) local X, save = rawget(new_G, i), select('#', ...)==0 and self or ... if i and i~=true and not (X and save and rawequal(X, save)) and rawset(new_G, i, save) and (X~=nil or save==nil and new_G[i]~=nil) then--rawequal in case X is another buffer local mG = getmetatable(new_G) or {__call=mG.__call} if mG.__index then pcall(rawset, mG.__index, i, X) else mG.__index = setmetatable(new_G, mG) and {[i] = X} end end return self, ...--avoiding __eq with rawequal(self,save) is overkill since buffers can self-save without being passed as save end, _R = function(self, i, v, m) if i~='new_G' then if i and i~=true then rawset(new_G, i , v) end elseif not v or v==true or v._G~=_G then new_G = setmetatable(v~=true and v or {}, {__call = mG.__call, __index = v~=true and m~=true and (m or new_G) or nil}) else new_G, (not m and (m~=nil or v==new_G) and Nil or getmetatable(v)).__index = v, m~=true and (m or new_G) or nil end--setting Nil.__index is noOp return self end, _2 = function(self, ...) if new_G[...]~=nil then return new_G[...] end--higher priority so Buffer:_G('new_G', ...) can prevent an overwrite if ...=='new_G' then return rawset((select('#', ...)~=1 and MBi._R(new_G, ...) or new_G), '_G', _G) end return select(select('#', ...)==1 and 1 or 2, self:_G(...))--return only one value; 'return select(2, self:_G(...)) or self' doesn't work for returning nil end, _B = function(self, v) return v or v==nil and Nil end } for k, v in next, gfuncs do MBi[k] = v end setmetatable(Nil,{__concat=MB.__concat,__newindex=noOp,__call=noOp,__tostring=noOp,__metatable=MB,__index=setmetatable({_B=MBi._B,_=function()return Nil end,last_concat=''}, {__index=function(t,i)return (MBi[i] or i and not tonumber(i)) and t._ or nil end})}) function mG.__call(G, k, ...) return (k._G or G.type(k)=='table') and (G.select('#', ...)~=1 and G.rawset(k, ...) or G:rawset(..., k) and k) or G:rawset(k, (...)) and ... end end local new = setmetatable({}, self) if ... and (...)==new_G then return select(2, ...) and MBmix(new:_G((select(2, ...))), select(3, ...)) or new end return ... and MBi._(new, ...) or new end, __index = function(t, i) MB = MB or t return MBi[i] and function(...) return MBi[i](setmetatable({}, t), select(...==t and 2 or 1,...)) end end }) a531c35e1366f84755b75caab181cd45e5330bbe Template:Yesno-no 10 42 82 2018-02-13T20:27:17Z wikipedia>WOSlinker 0 separate pp-template not needed wikitext text/x-wiki {{safesubst:<noinclude />yesno|{{{1}}}|yes={{{yes|yes}}}|no={{{no|no}}}|blank={{{blank|no}}}|¬={{{¬|no}}}|def={{{def|no}}}}}<noinclude> {{Documentation|Template:Yesno/doc}} <!--Categories go in the doc page referenced above; interwikis go in Wikidata.--> </noinclude> 1ad7b7800da1b867ead8f6ff8cef76e6201b3b56 Template:Asbox 10 26 84 2018-07-24T20:05:09Z wikipedia>RMCD bot 0 Removing notice of move discussion wikitext text/x-wiki <includeonly>{{#invoke:Asbox|main}}</includeonly><noinclude> {{documentation}} <!-- Add categories to the /doc subpage and interwikis to Wikidata. --> </noinclude> b20553d60f223a0f36a3089524989e235d379b74 Template:Template other 10 33 64 2018-12-16T22:06:25Z wikipedia>Amorymeltzer 0 Changed protection level for "[[Template:Template other]]": [[WP:High-risk templates|Highly visible template]]: Transclusion count has increased dramatically ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite)) wikitext text/x-wiki {{#switch: <!--If no or empty "demospace" parameter then detect namespace--> {{#if:{{{demospace|}}} | {{lc: {{{demospace}}} }} <!--Use lower case "demospace"--> | {{#ifeq:{{NAMESPACE}}|{{ns:Template}} | template | other }} }} | template = {{{1|}}} | other | #default = {{{2|}}} }}<!--End switch--><noinclude> {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 06fb13d264df967b5232141067eb7d2b67372d76 Template:Stub 10 25 52 2019-02-26T06:07:29Z wikipedia>Grutness 0 wikitext text/x-wiki {{asbox | image = | pix = | subject = | article = article | qualifier = | category = Stubs | tempsort = no | lowercase = y | name = Template:Stub }} c8372a9cd3ab0d8ef30c901442b93e0675510604 Template:Ombox 10 61 138 2020-04-01T06:12:36Z wikipedia>MusikAnimal 0 1 revision imported wikitext text/x-wiki {{#invoke:Message box|ombox}}<noinclude> {{documentation}} <!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --> </noinclude> 0e54065432d540737b9e56c4e3a8e7f74d4534ea Module:Arguments 828 9 56 2020-04-01T06:12:40Z wikipedia>MusikAnimal 0 1 revision imported Scribunto text/plain -- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke directly. local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType local arguments = {} -- Generate four different tidyVal functions, so that we don't have to check the -- options every time we call it. local function tidyValDefault(key, val) if type(val) == 'string' then val = val:match('^%s*(.-)%s*$') if val == '' then return nil else return val end else return val end end local function tidyValTrimOnly(key, val) if type(val) == 'string' then return val:match('^%s*(.-)%s*$') else return val end end local function tidyValRemoveBlanksOnly(key, val) if type(val) == 'string' then if val:find('%S') then return val else return nil end else return val end end local function tidyValNoChange(key, val) return val end local function matchesTitle(given, title) local tp = type( given ) return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title end local translate_mt = { __index = function(t, k) return k end } function arguments.getArgs(frame, options) checkType('getArgs', 1, frame, 'table', true) checkType('getArgs', 2, options, 'table', true) frame = frame or {} options = options or {} --[[ -- Set up argument translation. --]] options.translate = options.translate or {} if getmetatable(options.translate) == nil then setmetatable(options.translate, translate_mt) end if options.backtranslate == nil then options.backtranslate = {} for k,v in pairs(options.translate) do options.backtranslate[v] = k end end if options.backtranslate and getmetatable(options.backtranslate) == nil then setmetatable(options.backtranslate, { __index = function(t, k) if options.translate[k] ~= k then return nil else return k end end }) end --[[ -- Get the argument tables. If we were passed a valid frame object, get the -- frame arguments (fargs) and the parent frame arguments (pargs), depending -- on the options set and on the parent frame's availability. If we weren't -- passed a valid frame object, we are being called from another Lua module -- or from the debug console, so assume that we were passed a table of args -- directly, and assign it to a new variable (luaArgs). --]] local fargs, pargs, luaArgs if type(frame.args) == 'table' and type(frame.getParent) == 'function' then if options.wrappers then --[[ -- The wrappers option makes Module:Arguments look up arguments in -- either the frame argument table or the parent argument table, but -- not both. This means that users can use either the #invoke syntax -- or a wrapper template without the loss of performance associated -- with looking arguments up in both the frame and the parent frame. -- Module:Arguments will look up arguments in the parent frame -- if it finds the parent frame's title in options.wrapper; -- otherwise it will look up arguments in the frame object passed -- to getArgs. --]] local parent = frame:getParent() if not parent then fargs = frame.args else local title = parent:getTitle():gsub('/sandbox$', '') local found = false if matchesTitle(options.wrappers, title) then found = true elseif type(options.wrappers) == 'table' then for _,v in pairs(options.wrappers) do if matchesTitle(v, title) then found = true break end end end -- We test for false specifically here so that nil (the default) acts like true. if found or options.frameOnly == false then pargs = parent.args end if not found or options.parentOnly == false then fargs = frame.args end end else -- options.wrapper isn't set, so check the other options. if not options.parentOnly then fargs = frame.args end if not options.frameOnly then local parent = frame:getParent() pargs = parent and parent.args or nil end end if options.parentFirst then fargs, pargs = pargs, fargs end else luaArgs = frame end -- Set the order of precedence of the argument tables. If the variables are -- nil, nothing will be added to the table, which is how we avoid clashes -- between the frame/parent args and the Lua args. local argTables = {fargs} argTables[#argTables + 1] = pargs argTables[#argTables + 1] = luaArgs --[[ -- Generate the tidyVal function. If it has been specified by the user, we -- use that; if not, we choose one of four functions depending on the -- options chosen. This is so that we don't have to call the options table -- every time the function is called. --]] local tidyVal = options.valueFunc if tidyVal then if type(tidyVal) ~= 'function' then error( "bad value assigned to option 'valueFunc'" .. '(function expected, got ' .. type(tidyVal) .. ')', 2 ) end elseif options.trim ~= false then if options.removeBlanks ~= false then tidyVal = tidyValDefault else tidyVal = tidyValTrimOnly end else if options.removeBlanks ~= false then tidyVal = tidyValRemoveBlanksOnly else tidyVal = tidyValNoChange end end --[[ -- Set up the args, metaArgs and nilArgs tables. args will be the one -- accessed from functions, and metaArgs will hold the actual arguments. Nil -- arguments are memoized in nilArgs, and the metatable connects all of them -- together. --]] local args, metaArgs, nilArgs, metatable = {}, {}, {}, {} setmetatable(args, metatable) local function mergeArgs(tables) --[[ -- Accepts multiple tables as input and merges their keys and values -- into one table. If a value is already present it is not overwritten; -- tables listed earlier have precedence. We are also memoizing nil -- values, which can be overwritten if they are 's' (soft). --]] for _, t in ipairs(tables) do for key, val in pairs(t) do if metaArgs[key] == nil and nilArgs[key] ~= 'h' then local tidiedVal = tidyVal(key, val) if tidiedVal == nil then nilArgs[key] = 's' else metaArgs[key] = tidiedVal end end end end end --[[ -- Define metatable behaviour. Arguments are memoized in the metaArgs table, -- and are only fetched from the argument tables once. Fetching arguments -- from the argument tables is the most resource-intensive step in this -- module, so we try and avoid it where possible. For this reason, nil -- arguments are also memoized, in the nilArgs table. Also, we keep a record -- in the metatable of when pairs and ipairs have been called, so we do not -- run pairs and ipairs on the argument tables more than once. We also do -- not run ipairs on fargs and pargs if pairs has already been run, as all -- the arguments will already have been copied over. --]] metatable.__index = function (t, key) --[[ -- Fetches an argument when the args table is indexed. First we check -- to see if the value is memoized, and if not we try and fetch it from -- the argument tables. When we check memoization, we need to check -- metaArgs before nilArgs, as both can be non-nil at the same time. -- If the argument is not present in metaArgs, we also check whether -- pairs has been run yet. If pairs has already been run, we return nil. -- This is because all the arguments will have already been copied into -- metaArgs by the mergeArgs function, meaning that any other arguments -- must be nil. --]] if type(key) == 'string' then key = options.translate[key] end local val = metaArgs[key] if val ~= nil then return val elseif metatable.donePairs or nilArgs[key] then return nil end for _, argTable in ipairs(argTables) do local argTableVal = tidyVal(key, argTable[key]) if argTableVal ~= nil then metaArgs[key] = argTableVal return argTableVal end end nilArgs[key] = 'h' return nil end metatable.__newindex = function (t, key, val) -- This function is called when a module tries to add a new value to the -- args table, or tries to change an existing value. if type(key) == 'string' then key = options.translate[key] end if options.readOnly then error( 'could not write to argument table key "' .. tostring(key) .. '"; the table is read-only', 2 ) elseif options.noOverwrite and args[key] ~= nil then error( 'could not write to argument table key "' .. tostring(key) .. '"; overwriting existing arguments is not permitted', 2 ) elseif val == nil then --[[ -- If the argument is to be overwritten with nil, we need to erase -- the value in metaArgs, so that __index, __pairs and __ipairs do -- not use a previous existing value, if present; and we also need -- to memoize the nil in nilArgs, so that the value isn't looked -- up in the argument tables if it is accessed again. --]] metaArgs[key] = nil nilArgs[key] = 'h' else metaArgs[key] = val end end local function translatenext(invariant) local k, v = next(invariant.t, invariant.k) invariant.k = k if k == nil then return nil elseif type(k) ~= 'string' or not options.backtranslate then return k, v else local backtranslate = options.backtranslate[k] if backtranslate == nil then -- Skip this one. This is a tail call, so this won't cause stack overflow return translatenext(invariant) else return backtranslate, v end end end metatable.__pairs = function () -- Called when pairs is run on the args table. if not metatable.donePairs then mergeArgs(argTables) metatable.donePairs = true end return translatenext, { t = metaArgs } end local function inext(t, i) -- This uses our __index metamethod local v = t[i + 1] if v ~= nil then return i + 1, v end end metatable.__ipairs = function (t) -- Called when ipairs is run on the args table. return inext, t, 0 end return args end return arguments 3134ecce8429b810d445e29eae115e2ae4c36c53 Module:Yesno 828 11 54 2020-04-01T06:27:55Z wikipedia>MusikAnimal 0 Undid revision 948472533 by [[Special:Contributions/w>Vogone|w>Vogone]] ([[User talk:w>Vogone|talk]]) Scribunto text/plain -- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}. return function (val, default) -- If your wiki uses non-ascii characters for any of "yes", "no", etc., you -- should replace "val:lower()" with "mw.ustring.lower(val)" in the -- following line. val = type(val) == 'string' and val:lower() or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y' or val == 'true' or val == 't' or val == 'on' or tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n' or val == 'false' or val == 'f' or val == 'off' or tonumber(val) == 0 then return false else return default end end f767643e7d12126d020d88d662a3dd057817b9dc Module:File link 828 36 70 2020-04-01T06:31:54Z wikipedia>MusikAnimal 0 Undid revision 948472508 by [[Special:Contributions/w>IPad365|w>IPad365]] ([[User talk:w>IPad365|talk]]) Scribunto text/plain -- This module provides a library for formatting file wikilinks. local yesno = require('Module:Yesno') local checkType = require('libraryUtil').checkType local p = {} function p._main(args) checkType('_main', 1, args, 'table') -- This is basically libraryUtil.checkTypeForNamedArg, but we are rolling our -- own function to get the right error level. local function checkArg(key, val, level) if type(val) ~= 'string' then error(string.format( "type error in '%s' parameter of '_main' (expected string, got %s)", key, type(val) ), level) end end local ret = {} -- Adds a positional parameter to the buffer. local function addPositional(key) local val = args[key] if not val then return nil end checkArg(key, val, 4) ret[#ret + 1] = val end -- Adds a named parameter to the buffer. We assume that the parameter name -- is the same as the argument key. local function addNamed(key) local val = args[key] if not val then return nil end checkArg(key, val, 4) ret[#ret + 1] = key .. '=' .. val end -- Filename checkArg('file', args.file, 3) ret[#ret + 1] = 'File:' .. args.file -- Format if args.format then checkArg('format', args.format) if args.formatfile then checkArg('formatfile', args.formatfile) ret[#ret + 1] = args.format .. '=' .. args.formatfile else ret[#ret + 1] = args.format end end -- Border if yesno(args.border) then ret[#ret + 1] = 'border' end addPositional('location') addPositional('alignment') addPositional('size') addNamed('upright') addNamed('link') addNamed('alt') addNamed('page') addNamed('class') addNamed('lang') addNamed('start') addNamed('end') addNamed('thumbtime') addPositional('caption') return string.format('[[%s]]', table.concat(ret, '|')) end function p.main(frame) local origArgs = require('Module:Arguments').getArgs(frame, { wrappers = 'Template:File link' }) if not origArgs.file then error("'file' parameter missing from [[Template:File link]]", 0) end -- Copy the arguments that were passed to a new table to avoid looking up -- every possible parameter in the frame object. local args = {} for k, v in pairs(origArgs) do -- Make _BLANK a special argument to add a blank parameter. For use in -- conditional templates etc. it is useful for blank arguments to be -- ignored, but we still need a way to specify them so that we can do -- things like [[File:Example.png|link=]]. if v == '_BLANK' then v = '' end args[k] = v end return p._main(args) end return p 66925f088d11530f2482f04181a3baaaa0ad3d0c Template:Sandbox other 10 44 98 2020-04-03T00:08:09Z wikipedia>Evad37 0 Also match subpage names beginning with "sandbox", per [[Template_talk:Sandbox_other#Template-protected_edit_request_on_28_March_2020|edit request]] wikitext text/x-wiki {{#if:{{#ifeq:{{#invoke:String|sublength|s={{SUBPAGENAME}}|i=0|len=7}}|sandbox|1}}{{#ifeq:{{SUBPAGENAME}}|doc|1}}{{#invoke:String|match|{{PAGENAME}}|/sandbox/styles.css$|plain=false|nomatch=}}|{{{1|}}}|{{{2|}}}}}<!-- --><noinclude>{{documentation}}</noinclude> 91e4ae891d6b791615152c1fbc971414961ba872 Template:Yesno 10 30 58 2020-08-28T03:15:17Z wikipedia>Xaosflux 0 add additional paramerters, "t", "f" - requested on talk - worked in sandbox /testcases wikitext text/x-wiki {{<includeonly>safesubst:</includeonly>#switch: {{<includeonly>safesubst:</includeonly>lc: {{{1|¬}}} }} |no |n |f |false |off |0 = {{{no|<!-- null -->}}} | = {{{blank|{{{no|<!-- null -->}}}}}} |¬ = {{{¬|}}} |yes |y |t |true |on |1 = {{{yes|yes}}} |#default = {{{def|{{{yes|yes}}}}}} }}<noinclude> {{Documentation}} </noinclude> 629c2937bc5cf7cfe13cd2a598582af832782399 Template:Message box 10 54 118 2020-11-30T05:20:26Z wikipedia>Jonesey95 0 Only show lorem ipsum text here, not in transclusions. This template was showing lorem text on a Wikiproject page. wikitext text/x-wiki {{Mbox | image = {{#if:{{{image|}}}|[[Image:{{{image}}}|45px]]|none}} | style = {{#if:{{{backgroundcolor|}}}|background: {{{backgroundcolor}}}}} | text = {{#if:{{{heading|}}}|'''{{{heading|}}}'''<br />}}{{{message|{{{text|<noinclude>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</noinclude>}}}}}} | small = {{{small|}}} | smallimage = {{#if:{{{image|}}}|[[Image:{{{image}}}|30px]]|none}} }}<noinclude>{{Documentation}}<!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS --></noinclude> 3da822df71362ab9db8cae8bd8fc8b1318ba1d25 Template:Tl 10 56 122 2021-02-12T22:03:00Z wikipedia>Anthony Appleyard 0 Anthony Appleyard moved page [[Template:Tl]] to [[Template:Template link]]: [[Special:Permalink/1006428669|Requested]] by Buidhe at [[WP:RM/TR]]: RM closed as move wikitext text/x-wiki #REDIRECT [[Template:Template link]] {{Redirect category shell| {{R from move}} }} d6593bb3b4a866249f55d0f34b047a71fe1f1529 Template:Asbox/styles.css 10 28 86 2021-03-15T18:13:21Z wikipedia>Paine Ellsworth 0 per edit request on talk page - hide page overflow sanitized-css text/css /* {{pp-template}} */ /* Article stub message box styles */ .asbox { position: relative; overflow:hidden; } .asbox table { background: transparent; } .asbox p { margin: 0; } .asbox p + p { margin-top: 0.25em; } .asbox-body { font-style: italic; } .asbox-note { font-size: smaller; } .asbox .navbar { position: absolute; top: -0.75em; right: 1em; display: none; } 9f0904fdac11fd6eebd84c73d5680f09d19c9b5a Template:Template link 10 57 124 2021-03-25T19:03:22Z wikipedia>Izno 0 [[Wikipedia:Templates for discussion/Log/2021 March 18#Template:Tlu]] closed as keep ([[WP:XFDC#4.0.11|XFDcloser]]) wikitext text/x-wiki &#123;&#123;[[Template:{{{1}}}|{{{1}}}]]&#125;&#125;<noinclude>{{documentation}} <!-- Categories go on the /doc subpage and interwikis go on Wikidata. --> </noinclude> eabbec62efe3044a98ebb3ce9e7d4d43c222351d Module:Asbox 828 27 88 2021-08-19T05:19:44Z wikipedia>DannyS712 0 prevent global variable disallowedUnicodeChars, triggers warnings at [[Template:Ankylosaurian-stub]] - assuming it was by accident - please revert if this breaks anything Scribunto text/plain --[[ This module was created by User:CodeHydro (Alexander Zhikun He). User:Jackmcbarn and User:Mr._Stradivarius provided a great deal of assistance in writting p.main() p.main() draw heavily from the following version of Template:Asbox of the English Wikipedia, authored primarily by User:Rich_Farmbrough https://en.wikipedia.org/w/index.php?title=Template:Asbox&oldid=619510287 p.templatepage() is derived from the following revision of Template:Asbox/templatepage, authored primarily by User:MSGJ https://en.wikipedia.org/w/index.php?title=Template:Asbox/templatepage&oldid=632914791 Both templates had significant contributions from numerous others listed in the revision history tab of their respective pages. --]] local WRAPPER_TEMPLATE, args = 'Template:Asbox' local templatestyles = 'Asbox/styles.css' local p, Buffer, stubCats = { --Prevents dupli-cats... get it? Maybe not? cats = setmetatable({}, {__newindex = function(t, i, v) if not rawget(t, i) then rawset(t, i, v) table.insert(t, i) end end}), --initializes variables required by both p.main and p.templatepage init = function(self, frame, page) args, page = args or require('Module:Arguments').getArgs(frame, { wrappers = WRAPPER_TEMPLATE }), page or mw.title.getCurrentTitle() --Ensures demo parameter will never affect category() output for articles self.demo = self.demo or page.namespace ~= 0 and args.demo return args, page end }, require('Module:Buffer') --[[ Formats category links. Stores them until called with cat.done=true Takes multiple or single categories in the form of 'cat' or a table of strings and/or tables containing parts. (See below) ]] local attention, catTag, catKey = Buffer'Stub message templates needing attention', '[[Category:%s]]', '%s|%s%s' local function category(cat) for _, v in ipairs((tostring(cat) == cat or cat.t) and {cat} or cat) do --[[ If v is a table: [1] = full category name; defaults to local attention if blank k = Category sort key. Prefix before v.t t = page.text or args.tempsort#; appended after k (or in its place if omitted). Required if v is not a string Basically the same as v = (v[1] or attention) .. ' | ' .. (v.k or '') .. v.t ]] if v and v ~= true then--reject v = nil, false, or true p.cats[catTag:format(tostring(v) == v and v or (v[1] and Buffer(v[1]) or attention):_in(v.k):_(v.t):_str(2, nil, nil, '|') )] = true end end return cat.done and table.concat(p.cats, p.demo and ' | ' or nil) or '' end --[[ Makes an ombox warning; Takes table {ifNot = Boolean, text, {cat. sort key, cat. sort name}} Will return an empty string instead when ifNot evaluates to true ]] local function ombox(v) if v.ifNot then return end p.ombox = p.ombox or require('Module:Message box').ombox category{v[2]} return p.ombox{ type = 'content', text = v[1] } end --[[ Unlike original template, module now takes unlimited cats! This function also performs most stub category error checks except for the ombox for when main |category= is omitted (See p.template()) ]] local function catStub(page, pageDoc) stubCats = {missing = {}, v = {}} -- zwj and zwnj have semantical use in other other wikis, don't remove them local zwj = '\226\128\141' -- U+200D, E2 80 8D local zwnj = '\226\128\140' -- U+200C, E2 80 8C local disallowedUnicodeChars = '[^%w%p%s' .. zwj .. zwnj .. ']' -- for i18n we make this a separate string local code for k, _ in pairs(args) do --Find category parameters and store the number (main cat = '') table.insert(stubCats, string.match(k, '^category(%d*)$')) end table.sort(stubCats) for k, v in ipairs(stubCats) do --Get category names and, if called by p.templatepage, the optional sort key local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], disallowedUnicodeChars, '')--remove all hidden unicode chars --Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category. table.insert(stubCats.v, page and (--p.templatepage passes page; p.main does not, i.e. articles are categorized without sort keys. v=='' and tsort == 'no'--if true, inserts 'true' in table, which category() will reject or tsort and {cat, k = ' ', t = tsort} or {cat, k = ' *', t = page.text}--note space in front of sort key ) or cat ) --Check category existance only if on the template page (i.e. stub documentation) if page then if not mw.title.new('Category:' .. cat).exists then code = code or mw.html.create'code':wikitext'|category' table.insert(stubCats.missing, tostring(mw.clone(code):wikitext(v))) end --[[ Checks non-demo stub template for documentation and flags if doc is present. All stub cats names are checked and flagged if it does not match 'Category: [] stub'. The main stub cat is exempt from the name check if the stub template has its own doc (presumably, this doc would have an explanation as to why the main stub cat is non-conforming). ]] table.insert(stubCats.v, v == '' and not p.demo and pageDoc.exists and 'Stub message templates with documentation subpages' or not cat:match' stubs$' and {k = 'S', t = page.text} ) end end --Add category names after loop is completed category(stubCats.v) return #stubCats.missing > 0 and ombox{ --Changed, original msg: --One or more of the stub categories defined in this template do not seem to exist! --Please double-check the parameters {{para|category}}, {{para|category1}} and {{para|category2}}. 'The following parameter' .. (#stubCats.missing == 1 and ' defines a stub category that does' or 's define stub categories that do') .. ' not exist: ' .. mw.text.listToText(stubCats.missing), {k = 'N', t = page.text} } end --Shows population of categories found by catStub(). Outputs demo values if none local function population() local wikitext, base = {}, '* [[:Category:%s]] (population: %s)\n' if not args.category and stubCats[1] ~= false then table.insert(stubCats, 1, false) end for _, v in ipairs(stubCats) do table.insert(wikitext, base:format( v and args['category' .. v] or '{{{category}}}', v and mw.site.stats.pagesInCategory(args['category' .. v], 'all') or 0 )) end return table.concat(wikitext) end --Includes standard stub documention and flags stub templates with bad parameter values. function p.templatepage(frame, page) args, page = p:init(frame, page) local tStubDoc = mw.title.new'Template:Stub documentation' local pageDoc = page:subPageTitle('doc') --Reorganization note: Original Asbox alternates between outputting categories and checking on params |category#=. --Rather than checking multiple times and switching tasks, all stub category param operations have been rolled into catStub() return Buffer( ombox{--Show ombox warnings for missing args. ifNot = args.category, 'The <code>|category</code> parameter is not set. Please add an appropriate stub category.', {k = 'C', t = page.text} }) :_(ombox{ ifNot = args.subject or args.article or args.qualifier, 'This stub template contains no description! At least one of the parameters <code>|subject</code>, <code>|article</code> or <code>|qualifier</code> must be defined.', {k = 'D', t = page.text} }) :_(catStub(page, pageDoc))--catStub() may also return an ombox if there are non-existing categories :_(category{ done = p.demo ~= 'doc',--Outputs categories if not doc demo 'Stub message templates', args.icon and 'Stub message templates using icon parameter' or args.image and ( mw.title.new('Media:' .. mw.text.split(args.image, '|')[1]).exists--do nothing if exists. category() will reject true or {k = 'B', t = page.text} ) or 'Stub message templates without images', args.imagealt and {k = 'I', t = page.text}, }) :_((not p.demo or p.demo == 'doc') and--Add standard stub template documentation require('Module:Documentation').main{ content = Buffer(page.text ~= 'Stub' and--This comparison performed in {{Asbox/stubtree}} before it invokes Module:Asbox stubtree require('Module:Asbox stubtree').subtree{args = {pagename = page.text}} ) :_in'\n== About this template ==\nThis template is used to identify a':_(args.subject):_'stub':_(args.qualifier):_out' '--space :_'. It uses {{[[Template:Asbox|asbox]]}}, which is a meta-template designed to ease the process of creating and maintaining stub templates.\n=== Usage ===\nTyping ' :_(mw.html.create'code' :wikitext('{{', page.text == 'Stub' and 'stub' or page.text, '}}') ) :_' produces the message shown at the beginning, and adds the article to the following categor' :_(#stubCats > 1 and 'ies' or 'y') :_':\n' :_(population()) :_(pageDoc.exists and--transclusion of /doc if it exists frame:expandTemplate{title = pageDoc.text} ) :_'\n== General information ==\n' :_(frame:expandTemplate{title = tStubDoc.text}) :_'\n\n'(), ['link box'] = Buffer'This documentation is automatically generated by [[Module:Asbox]].' :_in'The general information is transcluded from [[Template:Stub documentation]]. ' :_(mw.html.create'span' :cssText'font-size:smaller;font-style:normal;line-height:130%' :node(('([%s edit] | [%s history])'):format( tStubDoc:fullUrl('action=edit', 'relative'), tStubDoc:fullUrl('action=history', 'relative') )) ) :_out() :_(page.protectionLevels.edit and page.protectionLevels.edit[1] == 'sysop' and "This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template's [" .. pageDoc:fullUrl('action=edit&preload=Template:Category_interwiki/preload', 'relative') .. '| /doc] subpage, which is not protected.' )' <br/>' } )() end function p.main(frame, page) args, page = p:init(frame, page) local output = mw.html.create'div' :attr{role = 'note'} :addClass'metadata plainlinks asbox stub' :tag'table' :attr{role = 'presentation'} :tag'tr' :addClass'noresize' :node((args.icon or args.image) and mw.html.create'td' :wikitext(args.icon or ('[[File:%s|%spx|alt=%s]]'):format( args.image or '', args.pix or '40x30', args.imagealt or 'Stub icon' )) ) :tag'td' :tag'p' :addClass'asbox-body' :wikitext( Buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space ' is a [[Wikipedia:stub|stub]]. You can help Wikipedia by [', page:fullUrl('action=edit', 'relative'), ' expanding it].' ) :done() :node(args.note and mw.html.create() :tag'p' :addClass'asbox-note' :wikitext(args.note) :done() ) :allDone() :node(args.name and require'Module:Navbar'._navbar{ args.name, mini = 'yes', } ) --[[ Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories. Articles using the template do not need a sort key since they have unique names. When p.demo equals 'doc', the demo stub categories will appear as those for a stub template. Otherwise, any non-nil p.demo will emulate article space categories (plus any error cats unless set to 'art') ]] if page.namespace == 0 then -- Main namespace category'All stub articles' catStub() elseif p.demo then if p.demo ~= 'doc' then catStub() end --Unless p.demo is set to 'art', it will also include error categories normally only shown on --the template but not in the article. The elseif after namespace == 0 means demo cats will never show in article space. p.demodoc = p.demo ~= 'art' and p.templatepage(frame, page) output = mw.html.create() :node(output) :tag'small':wikitext( 'Demo categories: ', (category{done = true}:gsub('(%[%[)(Category:)([^|%]]-)(%|)', '%1%2%3|%2%3%4'):gsub('(%[%[)(Category:)', '%1:%2')) ):done() :wikitext(p.demo == 'doc' and p.demodoc or nil) else --Checks for valid name; emulates original template's check using {{FULLPAGENAME:{{{name|}}}}} local normalizedName = mw.title.new(args.name or '') if normalizedName and normalizedName.fullText == page.fullText then output = mw.html.create():node(output):wikitext(p.templatepage(frame, page)) elseif not page.isSubpage and page.namespace == 10 then-- Template namespace and not a subpage category{{k = args.name and 'E' or 'W', t = page.text}} end end return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(output:wikitext(not p.demo and category{done = true} or nil)) end return p 0a9850f35fe9b15eaadd5d693d751ca62ddb60cf Template:Module other 10 62 140 2021-10-20T19:50:22Z wikipedia>MusikBot II 0 Changed protection settings for "[[Template:Module other]]": [[Wikipedia:High-risk templates|High-risk template or module]]: 3570 transclusions ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Require extended confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite)) wikitext text/x-wiki {{#switch: <!--If no or empty "demospace" parameter then detect namespace--> {{#if:{{{demospace|}}} | {{lc: {{{demospace}}} }} <!--Use lower case "demospace"--> | {{#ifeq:{{NAMESPACE}}|{{ns:Module}} | module | other }} }} | module = {{{1|}}} | other | #default = {{{2|}}} }}<!--End switch--><noinclude> {{documentation}} <!-- Add categories to the /doc subpage, not here! --> </noinclude> 503694836c1b07142e63fd35d8be69ec8bb9ffe7 Module:Navbar/styles.css 828 39 76 2022-01-03T23:12:15Z wikipedia>Izno 0 navbar styles that were moved to parent templates sanitized-css text/css /* {{pp|small=yes}} */ .navbar { display: inline; font-size: 88%; font-weight: normal; } .navbar-collapse { float: left; text-align: left; } .navbar-boxtext { word-spacing: 0; } .navbar ul { display: inline-block; white-space: nowrap; line-height: inherit; } .navbar-brackets::before { margin-right: -0.125em; content: '[ '; } .navbar-brackets::after { margin-left: -0.125em; content: ' ]'; } .navbar li { word-spacing: -0.125em; } .navbar a > span, .navbar a > abbr { text-decoration: inherit; } .navbar-mini abbr { font-variant: small-caps; border-bottom: none; text-decoration: none; cursor: inherit; } .navbar-ct-full { font-size: 114%; margin: 0 7em; } .navbar-ct-mini { font-size: 114%; margin: 0 4em; } 9d4056f949b4f0b159e3d40dfb1a5f01e72f9571 Module:Check for unknown parameters 828 31 60 2022-02-21T05:24:13Z wikipedia>BusterD 0 Changed protection settings for "[[Module:Check for unknown parameters]]": [[WP:High-risk templates|Highly visible template]]; requested at [[WP:RfPP]] ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite)) Scribunto text/plain -- This module may be used to compare the arguments passed to the parent -- with a list of arguments, returning a specified result if an argument is -- not on the list local p = {} local function trim(s) return s:match('^%s*(.-)%s*$') end local function isnotempty(s) return s and s:match('%S') end local function clean(text) -- Return text cleaned for display and truncated if too long. -- Strip markers are replaced with dummy text representing the original wikitext. local pos, truncated local function truncate(text) if truncated then return '' end if mw.ustring.len(text) > 25 then truncated = true text = mw.ustring.sub(text, 1, 25) .. '...' end return mw.text.nowiki(text) end local parts = {} for before, tag, remainder in text:gmatch('([^\127]*)\127[^\127]*%-(%l+)%-[^\127]*\127()') do pos = remainder table.insert(parts, truncate(before) .. '&lt;' .. tag .. '&gt;...&lt;/' .. tag .. '&gt;') end table.insert(parts, truncate(text:sub(pos or 1))) return table.concat(parts) end function p._check(args, pargs) if type(args) ~= "table" or type(pargs) ~= "table" then -- TODO: error handling return end -- create the list of known args, regular expressions, and the return string local knownargs = {} local regexps = {} for k, v in pairs(args) do if type(k) == 'number' then v = trim(v) knownargs[v] = 1 elseif k:find('^regexp[1-9][0-9]*$') then table.insert(regexps, '^' .. v .. '$') end end -- loop over the parent args, and make sure they are on the list local ignoreblank = isnotempty(args['ignoreblank']) local showblankpos = isnotempty(args['showblankpositional']) local values = {} for k, v in pairs(pargs) do if type(k) == 'string' and knownargs[k] == nil then local knownflag = false for _, regexp in ipairs(regexps) do if mw.ustring.match(k, regexp) then knownflag = true break end end if not knownflag and ( not ignoreblank or isnotempty(v) ) then table.insert(values, clean(k)) end elseif type(k) == 'number' and knownargs[tostring(k)] == nil then local knownflag = false for _, regexp in ipairs(regexps) do if mw.ustring.match(tostring(k), regexp) then knownflag = true break end end if not knownflag and ( showblankpos or isnotempty(v) ) then table.insert(values, k .. ' = ' .. clean(v)) end end end -- add results to the output tables local res = {} if #values > 0 then local unknown_text = args['unknown'] or 'Found _VALUE_, ' if mw.getCurrentFrame():preprocess( "{{REVISIONID}}" ) == "" then local preview_text = args['preview'] if isnotempty(preview_text) then preview_text = require('Module:If preview')._warning({preview_text}) elseif preview == nil then preview_text = unknown_text end unknown_text = preview_text end for _, v in pairs(values) do -- Fix odd bug for | = which gets stripped to the empty string and -- breaks category links if v == '' then v = ' ' end -- avoid error with v = 'example%2' ("invalid capture index") local r = unknown_text:gsub('_VALUE_', {_VALUE_ = v}) table.insert(res, r) end end return table.concat(res) end function p.check(frame) local args = frame.args local pargs = frame:getParent().args return p._check(args, pargs) end return p 93db6d115d4328d2a5148bb42959105e367b663e Module:Effective protection expiry 828 34 66 2022-02-23T10:59:29Z wikipedia>Xaosflux 0 Changed protection settings for "[[Module:Effective protection expiry]]": used in the mediawiki interface / match [[Module:Effective protection level]] ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite)) Scribunto text/plain local p = {} -- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known. -- If no title is specified, the title of the page being displayed is used. function p._main(action, pagename) local title if type(pagename) == 'table' and pagename.prefixedText then title = pagename elseif pagename then title = mw.title.new(pagename) else title = mw.title.getCurrentTitle() end pagename = title.prefixedText if action == 'autoreview' then local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title) return stabilitySettings and stabilitySettings.expiry or 'unknown' elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 ) end local rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename) if rawExpiry == 'infinity' then return 'infinity' elseif rawExpiry == '' then return 'unknown' else local year, month, day, hour, minute, second = rawExpiry:match( '^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$' ) if year then return string.format( '%s-%s-%sT%s:%s:%s', year, month, day, hour, minute, second ) else error('internal error in Module:Effective protection expiry; malformed expiry timestamp') end end end setmetatable(p, { __index = function(t, k) return function(frame) return t._main(k, frame.args[1]) end end }) return p 9a8c58dc2667232ed08a9b206a5d89ca8150312b Template:Documentation 10 14 130 2022-03-29T02:14:34Z wikipedia>Bsherr 0 consistent with new substitution template format wikitext text/x-wiki {{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}<noinclude> <!-- Add categories to the /doc subpage --> </noinclude> 9e62b964e96c4e3d478edecbfcb3c0338ae8a276 Module:Message box/ombox.css 828 60 134 2022-07-11T18:40:17Z wikipedia>Izno 0 and move mbox-small to 720px here as well sanitized-css text/css /* {{pp|small=y}} */ .ombox { margin: 4px 0; border-collapse: collapse; border: 1px solid #a2a9b1; /* Default "notice" gray */ background-color: #f8f9fa; box-sizing: border-box; } /* For the "small=yes" option. */ .ombox.mbox-small { font-size: 88%; line-height: 1.25em; } .ombox-speedy { border: 2px solid #b32424; /* Red */ background-color: #fee7e6; /* Pink */ } .ombox-delete { border: 2px solid #b32424; /* Red */ } .ombox-content { border: 1px solid #f28500; /* Orange */ } .ombox-style { border: 1px solid #fc3; /* Yellow */ } .ombox-move { border: 1px solid #9932cc; /* Purple */ } .ombox-protection { border: 2px solid #a2a9b1; /* Gray-gold */ } .ombox .mbox-text { border: none; /* @noflip */ padding: 0.25em 0.9em; width: 100%; } .ombox .mbox-image { border: none; /* @noflip */ padding: 2px 0 2px 0.9em; text-align: center; } .ombox .mbox-imageright { border: none; /* @noflip */ padding: 2px 0.9em 2px 0; text-align: center; } /* An empty narrow cell */ .ombox .mbox-empty-cell { border: none; padding: 0; width: 1px; } .ombox .mbox-invalid-type { text-align: center; } @media (min-width: 720px) { .ombox { margin: 4px 10%; } .ombox.mbox-small { /* @noflip */ clear: right; /* @noflip */ float: right; /* @noflip */ margin: 4px 0 4px 1em; width: 238px; } } 8fe3df4bb607e699eab2dbd23bd4a1a446391002 Template:Used in system 10 65 146 2022-08-20T15:58:28Z wikipedia>Pppery 0 Not an improvement - there's already a well-established edit request process starting with clicking "view source" and we don't need a duplicative process for the specific set of templates that are used in system messages wikitext text/x-wiki {{#invoke:High-use|main|1=|2={{{2|}}}|system={{#if:{{{1|}}}|{{{1}}}|in system messages}}<noinclude>|nocat=true</noinclude>}}<noinclude> {{documentation}}<!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 0abe278369db6cbbe319e7452d7644e27e11c532 Module:Protection banner 828 40 78 2022-10-21T08:07:11Z wikipedia>WOSlinker 0 use require('strict') instead of require('Module:No globals') Scribunto text/plain -- This module implements {{pp-meta}} and its daughter templates such as -- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}. -- Initialise necessary modules. require('strict') local makeFileLink = require('Module:File link')._main local effectiveProtectionLevel = require('Module:Effective protection level')._main local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main local yesno = require('Module:Yesno') -- Lazily initialise modules and objects we don't always need. local getArgs, makeMessageBox, lang -- Set constants. local CONFIG_MODULE = 'Module:Protection banner/config' -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function makeCategoryLink(cat, sort) if cat then return string.format( '[[%s:%s|%s]]', mw.site.namespaces[14].name, cat, sort ) end end -- Validation function for the expiry and the protection date local function validateDate(dateString, dateType) if not lang then lang = mw.language.getContentLanguage() end local success, result = pcall(lang.formatDate, lang, 'U', dateString) if success then result = tonumber(result) if result then return result end end error(string.format( 'invalid %s: %s', dateType, tostring(dateString) ), 4) end local function makeFullUrl(page, query, display) return string.format( '[%s %s]', tostring(mw.uri.fullUrl(page, query)), display ) end -- Given a directed graph formatted as node -> table of direct successors, -- get a table of all nodes reachable from a given node (though always -- including the given node). local function getReachableNodes(graph, start) local toWalk, retval = {[start] = true}, {} while true do -- Can't use pairs() since we're adding and removing things as we're iterating local k = next(toWalk) -- This always gets the "first" key if k == nil then return retval end toWalk[k] = nil retval[k] = true for _,v in ipairs(graph[k]) do if not retval[v] then toWalk[v] = true end end end end -------------------------------------------------------------------------------- -- Protection class -------------------------------------------------------------------------------- local Protection = {} Protection.__index = Protection Protection.supportedActions = { edit = true, move = true, autoreview = true, upload = true } Protection.bannerConfigFields = { 'text', 'explanation', 'tooltip', 'alt', 'link', 'image' } function Protection.new(args, cfg, title) local obj = {} obj._cfg = cfg obj.title = title or mw.title.getCurrentTitle() -- Set action if not args.action then obj.action = 'edit' elseif Protection.supportedActions[args.action] then obj.action = args.action else error(string.format( 'invalid action: %s', tostring(args.action) ), 3) end -- Set level obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title) if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then -- Users need to be autoconfirmed to move pages anyway, so treat -- semi-move-protected pages as unprotected. obj.level = '*' end -- Set expiry local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title) if effectiveExpiry == 'infinity' then obj.expiry = 'indef' elseif effectiveExpiry ~= 'unknown' then obj.expiry = validateDate(effectiveExpiry, 'expiry date') end -- Set reason if args[1] then obj.reason = mw.ustring.lower(args[1]) if obj.reason:find('|') then error('reasons cannot contain the pipe character ("|")', 3) end end -- Set protection date if args.date then obj.protectionDate = validateDate(args.date, 'protection date') end -- Set banner config do obj.bannerConfig = {} local configTables = {} if cfg.banners[obj.action] then configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason] end if cfg.defaultBanners[obj.action] then configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level] configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default end configTables[#configTables + 1] = cfg.masterBanner for i, field in ipairs(Protection.bannerConfigFields) do for j, t in ipairs(configTables) do if t[field] then obj.bannerConfig[field] = t[field] break end end end end return setmetatable(obj, Protection) end function Protection:isUserScript() -- Whether the page is a user JavaScript or CSS page. local title = self.title return title.namespace == 2 and ( title.contentModel == 'javascript' or title.contentModel == 'css' ) end function Protection:isProtected() return self.level ~= '*' end function Protection:shouldShowLock() -- Whether we should output a banner/padlock return self:isProtected() and not self:isUserScript() end -- Whether this page needs a protection category. Protection.shouldHaveProtectionCategory = Protection.shouldShowLock function Protection:isTemporary() return type(self.expiry) == 'number' end function Protection:makeProtectionCategory() if not self:shouldHaveProtectionCategory() then return '' end local cfg = self._cfg local title = self.title -- Get the expiry key fragment. local expiryFragment if self.expiry == 'indef' then expiryFragment = self.expiry elseif type(self.expiry) == 'number' then expiryFragment = 'temp' end -- Get the namespace key fragment. local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace] if not namespaceFragment and title.namespace % 2 == 1 then namespaceFragment = 'talk' end -- Define the order that key fragments are tested in. This is done with an -- array of tables containing the value to be tested, along with its -- position in the cfg.protectionCategories table. local order = { {val = expiryFragment, keypos = 1}, {val = namespaceFragment, keypos = 2}, {val = self.reason, keypos = 3}, {val = self.level, keypos = 4}, {val = self.action, keypos = 5} } --[[ -- The old protection templates used an ad-hoc protection category system, -- with some templates prioritising namespaces in their categories, and -- others prioritising the protection reason. To emulate this in this module -- we use the config table cfg.reasonsWithNamespacePriority to set the -- reasons for which namespaces have priority over protection reason. -- If we are dealing with one of those reasons, move the namespace table to -- the end of the order table, i.e. give it highest priority. If not, the -- reason should have highest priority, so move that to the end of the table -- instead. --]] table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3)) --[[ -- Define the attempt order. Inactive subtables (subtables with nil "value" -- fields) are moved to the end, where they will later be given the key -- "all". This is to cut down on the number of table lookups in -- cfg.protectionCategories, which grows exponentially with the number of -- non-nil keys. We keep track of the number of active subtables with the -- noActive parameter. --]] local noActive, attemptOrder do local active, inactive = {}, {} for i, t in ipairs(order) do if t.val then active[#active + 1] = t else inactive[#inactive + 1] = t end end noActive = #active attemptOrder = active for i, t in ipairs(inactive) do attemptOrder[#attemptOrder + 1] = t end end --[[ -- Check increasingly generic key combinations until we find a match. If a -- specific category exists for the combination of key fragments we are -- given, that match will be found first. If not, we keep trying different -- key fragment combinations until we match using the key -- "all-all-all-all-all". -- -- To generate the keys, we index the key subtables using a binary matrix -- with indexes i and j. j is only calculated up to the number of active -- subtables. For example, if there were three active subtables, the matrix -- would look like this, with 0 corresponding to the key fragment "all", and -- 1 corresponding to other key fragments. -- -- j 1 2 3 -- i -- 1 1 1 1 -- 2 0 1 1 -- 3 1 0 1 -- 4 0 0 1 -- 5 1 1 0 -- 6 0 1 0 -- 7 1 0 0 -- 8 0 0 0 -- -- Values of j higher than the number of active subtables are set -- to the string "all". -- -- A key for cfg.protectionCategories is constructed for each value of i. -- The position of the value in the key is determined by the keypos field in -- each subtable. --]] local cats = cfg.protectionCategories for i = 1, 2^noActive do local key = {} for j, t in ipairs(attemptOrder) do if j > noActive then key[t.keypos] = 'all' else local quotient = i / 2 ^ (j - 1) quotient = math.ceil(quotient) if quotient % 2 == 1 then key[t.keypos] = t.val else key[t.keypos] = 'all' end end end key = table.concat(key, '|') local attempt = cats[key] if attempt then return makeCategoryLink(attempt, title.text) end end return '' end function Protection:isIncorrect() local expiry = self.expiry return not self:shouldHaveProtectionCategory() or type(expiry) == 'number' and expiry < os.time() end function Protection:isTemplateProtectedNonTemplate() local action, namespace = self.action, self.title.namespace return self.level == 'templateeditor' and ( (action ~= 'edit' and action ~= 'move') or (namespace ~= 10 and namespace ~= 828) ) end function Protection:makeCategoryLinks() local msg = self._cfg.msg local ret = {self:makeProtectionCategory()} if self:isIncorrect() then ret[#ret + 1] = makeCategoryLink( msg['tracking-category-incorrect'], self.title.text ) end if self:isTemplateProtectedNonTemplate() then ret[#ret + 1] = makeCategoryLink( msg['tracking-category-template'], self.title.text ) end return table.concat(ret) end -------------------------------------------------------------------------------- -- Blurb class -------------------------------------------------------------------------------- local Blurb = {} Blurb.__index = Blurb Blurb.bannerTextFields = { text = true, explanation = true, tooltip = true, alt = true, link = true } function Blurb.new(protectionObj, args, cfg) return setmetatable({ _cfg = cfg, _protectionObj = protectionObj, _args = args }, Blurb) end -- Private methods -- function Blurb:_formatDate(num) -- Formats a Unix timestamp into dd Month, YYYY format. lang = lang or mw.language.getContentLanguage() local success, date = pcall( lang.formatDate, lang, self._cfg.msg['expiry-date-format'] or 'j F Y', '@' .. tostring(num) ) if success then return date end end function Blurb:_getExpandedMessage(msgKey) return self:_substituteParameters(self._cfg.msg[msgKey]) end function Blurb:_substituteParameters(msg) if not self._params then local parameterFuncs = {} parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter parameterFuncs.EDITREQUEST = self._makeEditRequestParameter parameterFuncs.EXPIRY = self._makeExpiryParameter parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter parameterFuncs.IMAGELINK = self._makeImageLinkParameter parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter parameterFuncs.PAGETYPE = self._makePagetypeParameter parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter parameterFuncs.TALKPAGE = self._makeTalkPageParameter parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter parameterFuncs.VANDAL = self._makeVandalTemplateParameter self._params = setmetatable({}, { __index = function (t, k) local param if parameterFuncs[k] then param = parameterFuncs[k](self) end param = param or '' t[k] = param return param end }) end msg = msg:gsub('${(%u+)}', self._params) return msg end function Blurb:_makeCurrentVersionParameter() -- A link to the page history or the move log, depending on the kind of -- protection. local pagename = self._protectionObj.title.prefixedText if self._protectionObj.action == 'move' then -- We need the move log link. return makeFullUrl( 'Special:Log', {type = 'move', page = pagename}, self:_getExpandedMessage('current-version-move-display') ) else -- We need the history link. return makeFullUrl( pagename, {action = 'history'}, self:_getExpandedMessage('current-version-edit-display') ) end end function Blurb:_makeEditRequestParameter() local mEditRequest = require('Module:Submit an edit request') local action = self._protectionObj.action local level = self._protectionObj.level -- Get the edit request type. local requestType if action == 'edit' then if level == 'autoconfirmed' then requestType = 'semi' elseif level == 'extendedconfirmed' then requestType = 'extended' elseif level == 'templateeditor' then requestType = 'template' end end requestType = requestType or 'full' -- Get the display value. local display = self:_getExpandedMessage('edit-request-display') return mEditRequest._link{type = requestType, display = display} end function Blurb:_makeExpiryParameter() local expiry = self._protectionObj.expiry if type(expiry) == 'number' then return self:_formatDate(expiry) else return expiry end end function Blurb:_makeExplanationBlurbParameter() -- Cover special cases first. if self._protectionObj.title.namespace == 8 then -- MediaWiki namespace return self:_getExpandedMessage('explanation-blurb-nounprotect') end -- Get explanation blurb table keys local action = self._protectionObj.action local level = self._protectionObj.level local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject' -- Find the message in the explanation blurb table and substitute any -- parameters. local explanations = self._cfg.explanationBlurbs local msg if explanations[action][level] and explanations[action][level][talkKey] then msg = explanations[action][level][talkKey] elseif explanations[action][level] and explanations[action][level].default then msg = explanations[action][level].default elseif explanations[action].default and explanations[action].default[talkKey] then msg = explanations[action].default[talkKey] elseif explanations[action].default and explanations[action].default.default then msg = explanations[action].default.default else error(string.format( 'could not find explanation blurb for action "%s", level "%s" and talk key "%s"', action, level, talkKey ), 8) end return self:_substituteParameters(msg) end function Blurb:_makeImageLinkParameter() local imageLinks = self._cfg.imageLinks local action = self._protectionObj.action local level = self._protectionObj.level local msg if imageLinks[action][level] then msg = imageLinks[action][level] elseif imageLinks[action].default then msg = imageLinks[action].default else msg = imageLinks.edit.default end return self:_substituteParameters(msg) end function Blurb:_makeIntroBlurbParameter() if self._protectionObj:isTemporary() then return self:_getExpandedMessage('intro-blurb-expiry') else return self:_getExpandedMessage('intro-blurb-noexpiry') end end function Blurb:_makeIntroFragmentParameter() if self._protectionObj:isTemporary() then return self:_getExpandedMessage('intro-fragment-expiry') else return self:_getExpandedMessage('intro-fragment-noexpiry') end end function Blurb:_makePagetypeParameter() local pagetypes = self._cfg.pagetypes return pagetypes[self._protectionObj.title.namespace] or pagetypes.default or error('no default pagetype defined', 8) end function Blurb:_makeProtectionBlurbParameter() local protectionBlurbs = self._cfg.protectionBlurbs local action = self._protectionObj.action local level = self._protectionObj.level local msg if protectionBlurbs[action][level] then msg = protectionBlurbs[action][level] elseif protectionBlurbs[action].default then msg = protectionBlurbs[action].default elseif protectionBlurbs.edit.default then msg = protectionBlurbs.edit.default else error('no protection blurb defined for protectionBlurbs.edit.default', 8) end return self:_substituteParameters(msg) end function Blurb:_makeProtectionDateParameter() local protectionDate = self._protectionObj.protectionDate if type(protectionDate) == 'number' then return self:_formatDate(protectionDate) else return protectionDate end end function Blurb:_makeProtectionLevelParameter() local protectionLevels = self._cfg.protectionLevels local action = self._protectionObj.action local level = self._protectionObj.level local msg if protectionLevels[action][level] then msg = protectionLevels[action][level] elseif protectionLevels[action].default then msg = protectionLevels[action].default elseif protectionLevels.edit.default then msg = protectionLevels.edit.default else error('no protection level defined for protectionLevels.edit.default', 8) end return self:_substituteParameters(msg) end function Blurb:_makeProtectionLogParameter() local pagename = self._protectionObj.title.prefixedText if self._protectionObj.action == 'autoreview' then -- We need the pending changes log. return makeFullUrl( 'Special:Log', {type = 'stable', page = pagename}, self:_getExpandedMessage('pc-log-display') ) else -- We need the protection log. return makeFullUrl( 'Special:Log', {type = 'protect', page = pagename}, self:_getExpandedMessage('protection-log-display') ) end end function Blurb:_makeTalkPageParameter() return string.format( '[[%s:%s#%s|%s]]', mw.site.namespaces[self._protectionObj.title.namespace].talk.name, self._protectionObj.title.text, self._args.section or 'top', self:_getExpandedMessage('talk-page-link-display') ) end function Blurb:_makeTooltipBlurbParameter() if self._protectionObj:isTemporary() then return self:_getExpandedMessage('tooltip-blurb-expiry') else return self:_getExpandedMessage('tooltip-blurb-noexpiry') end end function Blurb:_makeTooltipFragmentParameter() if self._protectionObj:isTemporary() then return self:_getExpandedMessage('tooltip-fragment-expiry') else return self:_getExpandedMessage('tooltip-fragment-noexpiry') end end function Blurb:_makeVandalTemplateParameter() return mw.getCurrentFrame():expandTemplate{ title="vandal-m", args={self._args.user or self._protectionObj.title.baseText} } end -- Public methods -- function Blurb:makeBannerText(key) -- Validate input. if not key or not Blurb.bannerTextFields[key] then error(string.format( '"%s" is not a valid banner config field', tostring(key) ), 2) end -- Generate the text. local msg = self._protectionObj.bannerConfig[key] if type(msg) == 'string' then return self:_substituteParameters(msg) elseif type(msg) == 'function' then msg = msg(self._protectionObj, self._args) if type(msg) ~= 'string' then error(string.format( 'bad output from banner config function with key "%s"' .. ' (expected string, got %s)', tostring(key), type(msg) ), 4) end return self:_substituteParameters(msg) end end -------------------------------------------------------------------------------- -- BannerTemplate class -------------------------------------------------------------------------------- local BannerTemplate = {} BannerTemplate.__index = BannerTemplate function BannerTemplate.new(protectionObj, cfg) local obj = {} obj._cfg = cfg -- Set the image filename. local imageFilename = protectionObj.bannerConfig.image if imageFilename then obj._imageFilename = imageFilename else -- If an image filename isn't specified explicitly in the banner config, -- generate it from the protection status and the namespace. local action = protectionObj.action local level = protectionObj.level local namespace = protectionObj.title.namespace local reason = protectionObj.reason -- Deal with special cases first. if ( namespace == 10 or namespace == 828 or reason and obj._cfg.indefImageReasons[reason] ) and action == 'edit' and level == 'sysop' and not protectionObj:isTemporary() then -- Fully protected modules and templates get the special red "indef" -- padlock. obj._imageFilename = obj._cfg.msg['image-filename-indef'] else -- Deal with regular protection types. local images = obj._cfg.images if images[action] then if images[action][level] then obj._imageFilename = images[action][level] elseif images[action].default then obj._imageFilename = images[action].default end end end end return setmetatable(obj, BannerTemplate) end function BannerTemplate:renderImage() local filename = self._imageFilename or self._cfg.msg['image-filename-default'] or 'Transparent.gif' return makeFileLink{ file = filename, size = (self.imageWidth or 20) .. 'px', alt = self._imageAlt, link = self._imageLink, caption = self.imageCaption } end -------------------------------------------------------------------------------- -- Banner class -------------------------------------------------------------------------------- local Banner = setmetatable({}, BannerTemplate) Banner.__index = Banner function Banner.new(protectionObj, blurbObj, cfg) local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb. obj.imageWidth = 40 obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip. obj._reasonText = blurbObj:makeBannerText('text') obj._explanationText = blurbObj:makeBannerText('explanation') obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing. return setmetatable(obj, Banner) end function Banner:__tostring() -- Renders the banner. makeMessageBox = makeMessageBox or require('Module:Message box').main local reasonText = self._reasonText or error('no reason text set', 2) local explanationText = self._explanationText local mbargs = { page = self._page, type = 'protection', image = self:renderImage(), text = string.format( "'''%s'''%s", reasonText, explanationText and '<br />' .. explanationText or '' ) } return makeMessageBox('mbox', mbargs) end -------------------------------------------------------------------------------- -- Padlock class -------------------------------------------------------------------------------- local Padlock = setmetatable({}, BannerTemplate) Padlock.__index = Padlock function Padlock.new(protectionObj, blurbObj, cfg) local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb. obj.imageWidth = 20 obj.imageCaption = blurbObj:makeBannerText('tooltip') obj._imageAlt = blurbObj:makeBannerText('alt') obj._imageLink = blurbObj:makeBannerText('link') obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action] or cfg.padlockIndicatorNames.default or 'pp-default' return setmetatable(obj, Padlock) end function Padlock:__tostring() local frame = mw.getCurrentFrame() -- The nowiki tag helps prevent whitespace at the top of articles. return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{ name = 'indicator', args = {name = self._indicatorName}, content = self:renderImage() } end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- This is used for testing purposes. return { Protection = Protection, Blurb = Blurb, BannerTemplate = BannerTemplate, Banner = Banner, Padlock = Padlock, } end function p._main(args, cfg, title) args = args or {} cfg = cfg or require(CONFIG_MODULE) local protectionObj = Protection.new(args, cfg, title) local ret = {} -- If a page's edit protection is equally or more restrictive than its -- protection from some other action, then don't bother displaying anything -- for the other action (except categories). if not yesno(args.catonly) and (protectionObj.action == 'edit' or args.demolevel or not getReachableNodes( cfg.hierarchy, protectionObj.level )[effectiveProtectionLevel('edit', protectionObj.title)]) then -- Initialise the blurb object local blurbObj = Blurb.new(protectionObj, args, cfg) -- Render the banner if protectionObj:shouldShowLock() then ret[#ret + 1] = tostring( (yesno(args.small) and Padlock or Banner) .new(protectionObj, blurbObj, cfg) ) end end -- Render the categories if yesno(args.category) ~= false then ret[#ret + 1] = protectionObj:makeCategoryLinks() end return table.concat(ret) end function p.main(frame, cfg) cfg = cfg or require(CONFIG_MODULE) -- Find default args, if any. local parent = frame.getParent and frame:getParent() local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')] -- Find user args, and use the parent frame if we are being called from a -- wrapper template. getArgs = getArgs or require('Module:Arguments').getArgs local userArgs = getArgs(frame, { parentOnly = defaultArgs, frameOnly = not defaultArgs }) -- Build the args table. User-specified args overwrite default args. local args = {} for k, v in pairs(defaultArgs or {}) do args[k] = v end for k, v in pairs(userArgs) do args[k] = v end return p._main(args, cfg) end return p 894f0884d4c2da1ce19d385b96f59af654b0946a Template:Mbox 10 55 120 2022-12-18T05:46:16Z wikipedia>TadejM 0 wikitext text/x-wiki {{#invoke:Message box|mbox}}<noinclude> {{documentation}} <!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! --> </noinclude> 5bfb2becf8bed35974b47e3ff8660dc14bee40c7 Template:Hlist/styles.css 10 53 116 2022-12-26T18:00:17Z wikipedia>Izno 0 actually remove that block, someone can dig for authorship sanitized-css text/css /* {{pp-protected|reason=match parent|small=yes}} */ /* * hlist styles are defined in core and Minerva and differ in Minerva. The * current definitions here (2023-01-01) are sufficient to override Minerva * without use of the hlist-separated class. The most problematic styles were * related to margin, padding, and the bullet. Check files listed at * [[MediaWiki talk:Common.css/to do#hlist-separated]] */ /* * TODO: When the majority of readership supports it (or some beautiful world * in which grade C support is above the minimum threshold), use :is() */ .hlist dl, .hlist ol, .hlist ul { margin: 0; padding: 0; } /* Display list items inline */ .hlist dd, .hlist dt, .hlist li { /* * don't trust the note that says margin doesn't work with inline * removing margin: 0 makes dds have margins again * We also want to reset margin-right in Minerva */ margin: 0; display: inline; } /* Display requested top-level lists inline */ .hlist.inline, .hlist.inline dl, .hlist.inline ol, .hlist.inline ul, /* Display nested lists inline */ .hlist dl dl, .hlist dl ol, .hlist dl ul, .hlist ol dl, .hlist ol ol, .hlist ol ul, .hlist ul dl, .hlist ul ol, .hlist ul ul { display: inline; } /* Hide empty list items */ .hlist .mw-empty-li { display: none; } /* TODO: :not() can maybe be used here to remove the later rule. naive test * seems to work. more testing needed. like so: *.hlist dt:not(:last-child)::after { * content: ": "; *} *.hlist dd:not(:last-child)::after, *.hlist li:not(:last-child)::after { * content: " · "; * font-weight: bold; *} */ /* Generate interpuncts */ .hlist dt::after { content: ": "; } .hlist dd::after, .hlist li::after { content: " · "; font-weight: bold; } .hlist dd:last-child::after, .hlist dt:last-child::after, .hlist li:last-child::after { content: none; } /* Add parentheses around nested lists */ .hlist dd dd:first-child::before, .hlist dd dt:first-child::before, .hlist dd li:first-child::before, .hlist dt dd:first-child::before, .hlist dt dt:first-child::before, .hlist dt li:first-child::before, .hlist li dd:first-child::before, .hlist li dt:first-child::before, .hlist li li:first-child::before { content: " ("; font-weight: normal; } .hlist dd dd:last-child::after, .hlist dd dt:last-child::after, .hlist dd li:last-child::after, .hlist dt dd:last-child::after, .hlist dt dt:last-child::after, .hlist dt li:last-child::after, .hlist li dd:last-child::after, .hlist li dt:last-child::after, .hlist li li:last-child::after { content: ")"; font-weight: normal; } /* Put ordinals in front of ordered list items */ .hlist ol { counter-reset: listitem; } .hlist ol > li { counter-increment: listitem; } .hlist ol > li::before { content: " " counter(listitem) "\a0"; } .hlist dd ol > li:first-child::before, .hlist dt ol > li:first-child::before, .hlist li ol > li:first-child::before { content: " (" counter(listitem) "\a0"; } 8c9dd9c9c00f30eead17fe10f51d183333e81f33 Module:Navbar/configuration 828 38 74 2022-12-29T18:18:21Z wikipedia>Izno 0 add hlist/styles.css Scribunto text/plain return { ['templatestyles'] = 'Module:Navbar/styles.css', ['hlist_templatestyles'] = 'Hlist/styles.css', ['box_text'] = 'This box: ', -- default text box when not plain or mini ['title_namespace'] = 'Template', -- namespace to default to for title ['invalid_title'] = 'Invalid title ', ['classes'] = { -- set a line to nil if you don't want it ['navbar'] = 'navbar', ['plainlinks'] = 'plainlinks', -- plainlinks ['horizontal_list'] = 'hlist', -- horizontal list class ['mini'] = 'navbar-mini', -- class indicating small links in the navbar ['this_box'] = 'navbar-boxtext', ['brackets'] = 'navbar-brackets', -- 'collapsible' is the key for a class to indicate the navbar is -- setting up the collapsible element in addition to the normal -- navbar. ['collapsible'] = 'navbar-collapse', ['collapsible_title_mini'] = 'navbar-ct-mini', ['collapsible_title_full'] = 'navbar-ct-full' } } b007c336b17ec4bcd4d5a9dca9f8cba301662b55 Template:Documentation subpage 10 45 100 2023-04-29T17:27:17Z wikipedia>Paine Ellsworth 0 m wikitext text/x-wiki <includeonly><!-- -->{{#ifeq:{{lc:{{SUBPAGENAME}}}} |{{{override|doc}}} | <!--(this template has been transcluded on a /doc or /{{{override}}} page)--> </includeonly><!-- -->{{#ifeq:{{{doc-notice|show}}} |show | {{Mbox | type = notice | style = margin-bottom:1.0em; | image = [[File:Edit-copy green.svg|40px|alt=|link=]] | text = {{strong|This is a [[Wikipedia:Template documentation|documentation]] [[Wikipedia:Subpages|subpage]]}} for {{terminate sentence|{{{1|[[:{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}}}}<br />It may contain usage information, [[Wikipedia:Categorization|categories]] and other content that is not part of the original {{#if:{{{text2|}}} |{{{text2}}} |{{#if:{{{text1|}}} |{{{text1}}} |{{#ifeq:{{SUBJECTSPACE}} |{{ns:User}} |{{lc:{{SUBJECTSPACE}}}} template page |{{#if:{{SUBJECTSPACE}} |{{lc:{{SUBJECTSPACE}}}} page|article}}}}}}}}. }} }}<!-- -->{{DEFAULTSORT:{{{defaultsort|{{PAGENAME}}}}}}}<!-- -->{{#if:{{{inhibit|}}} |<!--(don't categorize)--> | <includeonly><!-- -->{{#ifexist:{{NAMESPACE}}:{{BASEPAGENAME}} | [[Category:{{#switch:{{SUBJECTSPACE}} |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]] | [[Category:Documentation subpages without corresponding pages]] }}<!-- --></includeonly> }}<!-- (completing initial #ifeq: at start of template:) --><includeonly> | <!--(this template has not been transcluded on a /doc or /{{{override}}} page)--> }}<!-- --></includeonly><noinclude>{{Documentation}}</noinclude> 41ca90af0945442788a2dbd08c8c54a61a23c057 Template:Message box/doc 10 59 132 2023-05-30T07:32:41Z wikipedia>WOSlinker 0 syntaxhighlight lang="wikitext" wikitext text/x-wiki {{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> ==Usage== <syntaxhighlight lang="wikitext">{{Message_box |backgroundcolor = |image = |heading = |message = }} </syntaxhighlight> *'''backgroundcolor''': Box background color (default may depend on skin) *'''image''': Name of image (do not use "Image:" or "File:" heading) *'''heading''': Heading text *'''message''' or '''text''': Message text ==See also== *{{tl|Message}} *{{tl|Mbox}} *[[Message box]] <includeonly>{{sandbox other|| [[Category:Template namespace templates]] [[Category:Wikipedia message box templates| ]] }}</includeonly> 91f7f5df4c8ef4fcec461da62a088d5b7391ce77 Module:Transclusion count 828 49 108 2023-05-30T20:51:38Z wikipedia>Isabelle Belato 0 Changed protection settings for "[[Module:Transclusion count]]": [[WP:High-risk templates|Highly visible template]]; requested at [[WP:RfPP]] ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)) Scribunto text/plain local p = {} function p.fetch(frame) local template = nil local return_value = nil -- Use demo parameter if it exists, otherswise use current template name local namespace = mw.title.getCurrentTitle().namespace if frame.args["demo"] and frame.args["demo"] ~= "" then template = mw.ustring.gsub(frame.args["demo"],"^[Tt]emplate:","") elseif namespace == 10 then -- Template namespace template = mw.title.getCurrentTitle().text elseif namespace == 828 then -- Module namespace template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text) end -- If in template or module namespace, look up count in /data if template ~= nil then namespace = mw.title.new(template, "Template").namespace if namespace == 10 or namespace == 828 then template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end template = mw.ustring.gsub(template, "/sandbox$", "") -- strip /sandbox from end local index = mw.ustring.sub(mw.title.new(template).text,1,1) local status, data = pcall(function () return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other"))) end) if status then return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")]) end end end -- If database value doesn't exist, use value passed to template if return_value == nil and frame.args[1] ~= nil then local arg1=mw.ustring.match(frame.args[1], '[%d,]+') if arg1 and arg1 ~= '' then return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R')) end end return return_value end -- Tabulate this data for [[Wikipedia:Database reports/Templates transcluded on the most pages]] function p.tabulate(frame) local list = {} for i = 65, 91 do local data = mw.loadData('Module:Transclusion count/data/' .. ((i == 91) and 'other' or string.char(i))) for name, count in pairs(data) do table.insert(list, {mw.title.new(name, "Template").fullText, count}) end end table.sort(list, function(a, b) return (a[2] == b[2]) and (a[1] < b[1]) or (a[2] > b[2]) end) local lang = mw.getContentLanguage(); for i = 1, #list do list[i] = ('|-\n| %d || [[%s]] || %s\n'):format(i, list[i][1]:gsub('_', ' '), lang:formatNum(list[i][2])) end return table.concat(list) end return p 000ef6bcbf7b66e727870b0c300c4009da300513 Module:Message box 828 10 126 2023-09-02T22:54:30Z wikipedia>Anomie 0 [[:File:Cscr-featured.svg]] needs a link to the description page for license and attribution. Add the ability for the configuration to specify a flag to accomplish this. Scribunto text/plain require('strict') local getArgs local yesno = require('Module:Yesno') local lang = mw.language.getContentLanguage() local CONFIG_MODULE = 'Module:Message box/configuration' local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function getTitleObject(...) -- Get the title object, passing the function through pcall -- in case we are over the expensive function count limit. local success, title = pcall(mw.title.new, ...) if success then return title end end local function union(t1, t2) -- Returns the union of two arrays. local vals = {} for i, v in ipairs(t1) do vals[v] = true end for i, v in ipairs(t2) do vals[v] = true end local ret = {} for k in pairs(vals) do table.insert(ret, k) end table.sort(ret) return ret end local function getArgNums(args, prefix) local nums = {} for k, v in pairs(args) do local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end -------------------------------------------------------------------------------- -- Box class definition -------------------------------------------------------------------------------- local MessageBox = {} MessageBox.__index = MessageBox function MessageBox.new(boxType, args, cfg) args = args or {} local obj = {} -- Set the title object and the namespace. obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle() -- Set the config for our box type. obj.cfg = cfg[boxType] if not obj.cfg then local ns = obj.title.namespace -- boxType is "mbox" or invalid input if args.demospace and args.demospace ~= '' then -- implement demospace parameter of mbox local demospace = string.lower(args.demospace) if DEMOSPACES[demospace] then -- use template from DEMOSPACES obj.cfg = cfg[DEMOSPACES[demospace]] elseif string.find( demospace, 'talk' ) then -- demo as a talk page obj.cfg = cfg.tmbox else -- default to ombox obj.cfg = cfg.ombox end elseif ns == 0 then obj.cfg = cfg.ambox -- main namespace elseif ns == 6 then obj.cfg = cfg.imbox -- file namespace elseif ns == 14 then obj.cfg = cfg.cmbox -- category namespace else local nsTable = mw.site.namespaces[ns] if nsTable and nsTable.isTalk then obj.cfg = cfg.tmbox -- any talk namespace else obj.cfg = cfg.ombox -- other namespaces or invalid input end end end -- Set the arguments, and remove all blank arguments except for the ones -- listed in cfg.allowBlankParams. do local newArgs = {} for k, v in pairs(args) do if v ~= '' then newArgs[k] = v end end for i, param in ipairs(obj.cfg.allowBlankParams or {}) do newArgs[param] = args[param] end obj.args = newArgs end -- Define internal data structure. obj.categories = {} obj.classes = {} -- For lazy loading of [[Module:Category handler]]. obj.hasCategories = false return setmetatable(obj, MessageBox) end function MessageBox:addCat(ns, cat, sort) if not cat then return nil end if sort then cat = string.format('[[Category:%s|%s]]', cat, sort) else cat = string.format('[[Category:%s]]', cat) end self.hasCategories = true self.categories[ns] = self.categories[ns] or {} table.insert(self.categories[ns], cat) end function MessageBox:addClass(class) if not class then return nil end table.insert(self.classes, class) end function MessageBox:setParameters() local args = self.args local cfg = self.cfg -- Get type data. self.type = args.type local typeData = cfg.types[self.type] self.invalidTypeError = cfg.showInvalidTypeError and self.type and not typeData typeData = typeData or cfg.types[cfg.default] self.typeClass = typeData.class self.typeImage = typeData.image self.typeImageNeedsLink = typeData.imageNeedsLink -- Find if the box has been wrongly substituted. self.isSubstituted = cfg.substCheck and args.subst == 'SUBST' -- Find whether we are using a small message box. self.isSmall = cfg.allowSmall and ( cfg.smallParam and args.small == cfg.smallParam or not cfg.smallParam and yesno(args.small) ) -- Add attributes, classes and styles. self.id = args.id self.name = args.name if self.name then self:addClass('box-' .. string.gsub(self.name,' ','_')) end if yesno(args.plainlinks) ~= false then self:addClass('plainlinks') end for _, class in ipairs(cfg.classes or {}) do self:addClass(class) end if self.isSmall then self:addClass(cfg.smallClass or 'mbox-small') end self:addClass(self.typeClass) self:addClass(args.class) self.style = args.style self.attrs = args.attrs -- Set text style. self.textstyle = args.textstyle -- Find if we are on the template page or not. This functionality is only -- used if useCollapsibleTextFields is set, or if both cfg.templateCategory -- and cfg.templateCategoryRequireName are set. self.useCollapsibleTextFields = cfg.useCollapsibleTextFields if self.useCollapsibleTextFields or cfg.templateCategory and cfg.templateCategoryRequireName then if self.name then local templateName = mw.ustring.match( self.name, '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' ) or self.name templateName = 'Template:' .. templateName self.templateTitle = getTitleObject(templateName) end self.isTemplatePage = self.templateTitle and mw.title.equals(self.title, self.templateTitle) end -- Process data for collapsible text fields. At the moment these are only -- used in {{ambox}}. if self.useCollapsibleTextFields then -- Get the self.issue value. if self.isSmall and args.smalltext then self.issue = args.smalltext else local sect if args.sect == '' then sect = 'This ' .. (cfg.sectionDefault or 'page') elseif type(args.sect) == 'string' then sect = 'This ' .. args.sect end local issue = args.issue issue = type(issue) == 'string' and issue ~= '' and issue or nil local text = args.text text = type(text) == 'string' and text or nil local issues = {} table.insert(issues, sect) table.insert(issues, issue) table.insert(issues, text) self.issue = table.concat(issues, ' ') end -- Get the self.talk value. local talk = args.talk -- Show talk links on the template page or template subpages if the talk -- parameter is blank. if talk == '' and self.templateTitle and ( mw.title.equals(self.templateTitle, self.title) or self.title:isSubpageOf(self.templateTitle) ) then talk = '#' elseif talk == '' then talk = nil end if talk then -- If the talk value is a talk page, make a link to that page. Else -- assume that it's a section heading, and make a link to the talk -- page of the current page with that section heading. local talkTitle = getTitleObject(talk) local talkArgIsTalkPage = true if not talkTitle or not talkTitle.isTalkPage then talkArgIsTalkPage = false talkTitle = getTitleObject( self.title.text, mw.site.namespaces[self.title.namespace].talk.id ) end if talkTitle and talkTitle.exists then local talkText if self.isSmall then local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk) talkText = string.format('([[%s|talk]])', talkLink) else talkText = 'Relevant discussion may be found on' if talkArgIsTalkPage then talkText = string.format( '%s [[%s|%s]].', talkText, talk, talkTitle.prefixedText ) else talkText = string.format( '%s the [[%s#%s|talk page]].', talkText, talkTitle.prefixedText, talk ) end end self.talk = talkText end end -- Get other values. self.fix = args.fix ~= '' and args.fix or nil local date if args.date and args.date ~= '' then date = args.date elseif args.date == '' and self.isTemplatePage then date = lang:formatDate('F Y') end if date then self.date = string.format(" <span class='date-container'><i>(<span class='date'>%s</span>)</i></span>", date) end self.info = args.info if yesno(args.removalnotice) then self.removalNotice = cfg.removalNotice end end -- Set the non-collapsible text field. At the moment this is used by all box -- types other than ambox, and also by ambox when small=yes. if self.isSmall then self.text = args.smalltext or args.text else self.text = args.text end -- Set the below row. self.below = cfg.below and args.below -- General image settings. self.imageCellDiv = not self.isSmall and cfg.imageCellDiv self.imageEmptyCell = cfg.imageEmptyCell -- Left image settings. local imageLeft = self.isSmall and args.smallimage or args.image if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none' or not cfg.imageCheckBlank and imageLeft ~= 'none' then self.imageLeft = imageLeft if not imageLeft then local imageSize = self.isSmall and (cfg.imageSmallSize or '30x30px') or '40x40px' self.imageLeft = string.format('[[File:%s|%s%s|alt=]]', self.typeImage or 'Information icon4.svg', imageSize, self.typeImageNeedsLink and "" or "|link=" ) end end -- Right image settings. local imageRight = self.isSmall and args.smallimageright or args.imageright if not (cfg.imageRightNone and imageRight == 'none') then self.imageRight = imageRight end -- set templatestyles self.base_templatestyles = cfg.templatestyles self.templatestyles = args.templatestyles end function MessageBox:setMainspaceCategories() local args = self.args local cfg = self.cfg if not cfg.allowMainspaceCategories then return nil end local nums = {} for _, prefix in ipairs{'cat', 'category', 'all'} do args[prefix .. '1'] = args[prefix] nums = union(nums, getArgNums(args, prefix)) end -- The following is roughly equivalent to the old {{Ambox/category}}. local date = args.date date = type(date) == 'string' and date local preposition = 'from' for _, num in ipairs(nums) do local mainCat = args['cat' .. tostring(num)] or args['category' .. tostring(num)] local allCat = args['all' .. tostring(num)] mainCat = type(mainCat) == 'string' and mainCat allCat = type(allCat) == 'string' and allCat if mainCat and date and date ~= '' then local catTitle = string.format('%s %s %s', mainCat, preposition, date) self:addCat(0, catTitle) catTitle = getTitleObject('Category:' .. catTitle) if not catTitle or not catTitle.exists then self:addCat(0, 'Articles with invalid date parameter in template') end elseif mainCat and (not date or date == '') then self:addCat(0, mainCat) end if allCat then self:addCat(0, allCat) end end end function MessageBox:setTemplateCategories() local args = self.args local cfg = self.cfg -- Add template categories. if cfg.templateCategory then if cfg.templateCategoryRequireName then if self.isTemplatePage then self:addCat(10, cfg.templateCategory) end elseif not self.title.isSubpage then self:addCat(10, cfg.templateCategory) end end -- Add template error categories. if cfg.templateErrorCategory then local templateErrorCategory = cfg.templateErrorCategory local templateCat, templateSort if not self.name and not self.title.isSubpage then templateCat = templateErrorCategory elseif self.isTemplatePage then local paramsToCheck = cfg.templateErrorParamsToCheck or {} local count = 0 for i, param in ipairs(paramsToCheck) do if not args[param] then count = count + 1 end end if count > 0 then templateCat = templateErrorCategory templateSort = tostring(count) end if self.categoryNums and #self.categoryNums > 0 then templateCat = templateErrorCategory templateSort = 'C' end end self:addCat(10, templateCat, templateSort) end end function MessageBox:setAllNamespaceCategories() -- Set categories for all namespaces. if self.invalidTypeError then local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort) end if self.isSubstituted then self:addCat('all', 'Pages with incorrectly substituted templates') end end function MessageBox:setCategories() if self.title.namespace == 0 then self:setMainspaceCategories() elseif self.title.namespace == 10 then self:setTemplateCategories() end self:setAllNamespaceCategories() end function MessageBox:renderCategories() if not self.hasCategories then -- No categories added, no need to pass them to Category handler so, -- if it was invoked, it would return the empty string. -- So we shortcut and return the empty string. return "" end -- Convert category tables to strings and pass them through -- [[Module:Category handler]]. return require('Module:Category handler')._main{ main = table.concat(self.categories[0] or {}), template = table.concat(self.categories[10] or {}), all = table.concat(self.categories.all or {}), nocat = self.args.nocat, page = self.args.page } end function MessageBox:export() local root = mw.html.create() -- Add the subst check error. if self.isSubstituted and self.name then root:tag('b') :addClass('error') :wikitext(string.format( 'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.', mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') )) end local frame = mw.getCurrentFrame() root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = self.base_templatestyles }, }) -- Add support for a single custom templatestyles sheet. Undocumented as -- need should be limited and many templates using mbox are substed; we -- don't want to spread templatestyles sheets around to arbitrary places if self.templatestyles then root:wikitext(frame:extensionTag{ name = 'templatestyles', args = { src = self.templatestyles }, }) end -- Create the box table. local boxTable = root:tag('table') boxTable:attr('id', self.id or nil) for i, class in ipairs(self.classes or {}) do boxTable:addClass(class or nil) end boxTable :cssText(self.style or nil) :attr('role', 'presentation') if self.attrs then boxTable:attr(self.attrs) end -- Add the left-hand image. local row = boxTable:tag('tr') if self.imageLeft then local imageLeftCell = row:tag('td'):addClass('mbox-image') if self.imageCellDiv then -- If we are using a div, redefine imageLeftCell so that the image -- is inside it. Divs use style="width: 52px;", which limits the -- image width to 52px. If any images in a div are wider than that, -- they may overlap with the text or cause other display problems. imageLeftCell = imageLeftCell:tag('div'):addClass('mbox-image-div') end imageLeftCell:wikitext(self.imageLeft or nil) elseif self.imageEmptyCell then -- Some message boxes define an empty cell if no image is specified, and -- some don't. The old template code in templates where empty cells are -- specified gives the following hint: "No image. Cell with some width -- or padding necessary for text cell to have 100% width." row:tag('td') :addClass('mbox-empty-cell') end -- Add the text. local textCell = row:tag('td'):addClass('mbox-text') if self.useCollapsibleTextFields then -- The message box uses advanced text parameters that allow things to be -- collapsible. At the moment, only ambox uses this. textCell:cssText(self.textstyle or nil) local textCellDiv = textCell:tag('div') textCellDiv :addClass('mbox-text-span') :wikitext(self.issue or nil) if (self.talk or self.fix) then textCellDiv:tag('span') :addClass('hide-when-compact') :wikitext(self.talk and (' ' .. self.talk) or nil) :wikitext(self.fix and (' ' .. self.fix) or nil) end textCellDiv:wikitext(self.date and (' ' .. self.date) or nil) if self.info and not self.isSmall then textCellDiv :tag('span') :addClass('hide-when-compact') :wikitext(self.info and (' ' .. self.info) or nil) end if self.removalNotice then textCellDiv:tag('span') :addClass('hide-when-compact') :tag('i') :wikitext(string.format(" (%s)", self.removalNotice)) end else -- Default text formatting - anything goes. textCell :cssText(self.textstyle or nil) :wikitext(self.text or nil) end -- Add the right-hand image. if self.imageRight then local imageRightCell = row:tag('td'):addClass('mbox-imageright') if self.imageCellDiv then -- If we are using a div, redefine imageRightCell so that the image -- is inside it. imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div') end imageRightCell :wikitext(self.imageRight or nil) end -- Add the below row. if self.below then boxTable:tag('tr') :tag('td') :attr('colspan', self.imageRight and '3' or '2') :addClass('mbox-text') :cssText(self.textstyle or nil) :wikitext(self.below or nil) end -- Add error message for invalid type parameters. if self.invalidTypeError then root:tag('div') :addClass('mbox-invalid-type') :wikitext(string.format( 'This message box is using an invalid "type=%s" parameter and needs fixing.', self.type or '' )) end -- Add categories. root:wikitext(self:renderCategories() or nil) return tostring(root) end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p, mt = {}, {} function p._exportClasses() -- For testing. return { MessageBox = MessageBox } end function p.main(boxType, args, cfgTables) local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE)) box:setParameters() box:setCategories() return box:export() end function mt.__index(t, k) return function (frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) end end return setmetatable(p, mt) f2fb84f7b817d2d88747f57c40902a0d8be8158a Module:Navbar 828 37 72 2023-10-10T22:34:57Z wikipedia>Pppery 0 Per edit request on talk Scribunto text/plain local p = {} local cfg = mw.loadData('Module:Navbar/configuration') local function get_title_arg(is_collapsible, template) local title_arg = 1 if is_collapsible then title_arg = 2 end if template then title_arg = 'template' end return title_arg end local function choose_links(template, args) -- The show table indicates the default displayed items. -- view, talk, edit, hist, move, watch -- TODO: Move to configuration. local show = {true, true, true, false, false, false} if template then show[2] = false show[3] = false local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6, talk = 2, edit = 3, hist = 4, move = 5, watch = 6} -- TODO: Consider removing TableTools dependency. for _, v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do local num = index[v] if num then show[num] = true end end end local remove_edit_link = args.noedit if remove_edit_link then show[3] = false end return show end local function add_link(link_description, ul, is_mini, font_style) local l if link_description.url then l = {'[', '', ']'} else l = {'[[', '|', ']]'} end ul:tag('li') :addClass('nv-' .. link_description.full) :wikitext(l[1] .. link_description.link .. l[2]) :tag(is_mini and 'abbr' or 'span') :attr('title', link_description.html_title) :cssText(font_style) :wikitext(is_mini and link_description.mini or link_description.full) :done() :wikitext(l[3]) :done() end local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style) local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace) if not title then error(cfg.invalid_title .. title_text) end local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or '' -- TODO: Get link_descriptions and show into the configuration module. -- link_descriptions should be easier... local link_descriptions = { { ['mini'] = 'v', ['full'] = 'view', ['html_title'] = 'View this template', ['link'] = title.fullText, ['url'] = false }, { ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template', ['link'] = talkpage, ['url'] = false }, { ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template', ['link'] = 'Special:EditPage/' .. title.fullText, ['url'] = false }, { ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template', ['link'] = 'Special:PageHistory/' .. title.fullText, ['url'] = false }, { ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template', ['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true }, { ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template', ['link'] = title:fullUrl('action=watch'), ['url'] = true } } local ul = mw.html.create('ul') if has_brackets then ul:addClass(cfg.classes.brackets) :cssText(font_style) end for i, _ in ipairs(displayed_links) do if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end end return ul:done() end function p._navbar(args) -- TODO: We probably don't need both fontstyle and fontcolor... local font_style = args.fontstyle local font_color = args.fontcolor local is_collapsible = args.collapsible local is_mini = args.mini local is_plain = args.plain local collapsible_class = nil if is_collapsible then collapsible_class = cfg.classes.collapsible if not is_plain then is_mini = 1 end if font_color then font_style = (font_style or '') .. '; color: ' .. font_color .. ';' end end local navbar_style = args.style local div = mw.html.create():tag('div') div :addClass(cfg.classes.navbar) :addClass(cfg.classes.plainlinks) :addClass(cfg.classes.horizontal_list) :addClass(collapsible_class) -- we made the determination earlier :cssText(navbar_style) if is_mini then div:addClass(cfg.classes.mini) end local box_text = (args.text or cfg.box_text) .. ' ' -- the concatenated space guarantees the box text is separated if not (is_mini or is_plain) then div :tag('span') :addClass(cfg.classes.box_text) :cssText(font_style) :wikitext(box_text) end local template = args.template local displayed_links = choose_links(template, args) local has_brackets = args.brackets local title_arg = get_title_arg(is_collapsible, template) local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle()) local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style) div:node(list) if is_collapsible then local title_text_class if is_mini then title_text_class = cfg.classes.collapsible_title_mini else title_text_class = cfg.classes.collapsible_title_full end div:done() :tag('div') :addClass(title_text_class) :cssText(font_style) :wikitext(args[1]) end local frame = mw.getCurrentFrame() -- hlist -> navbar is best-effort to preserve old Common.css ordering. return frame:extensionTag{ name = 'templatestyles', args = { src = cfg.hlist_templatestyles } } .. frame:extensionTag{ name = 'templatestyles', args = { src = cfg.templatestyles } } .. tostring(div:done()) end function p.navbar(frame) return p._navbar(require('Module:Arguments').getArgs(frame)) end return p 047f307758c878eb3e99ed1768cc40920a6ec5fa Module:String 828 32 62 2023-10-25T18:17:50Z wikipedia>Trappist the monk 0 Scribunto text/plain --[[ This module is intended to provide access to basic string functions. Most of the functions provided here can be invoked with named parameters, unnamed parameters, or a mixture. If named parameters are used, Mediawiki will automatically remove any leading or trailing whitespace from the parameter. Depending on the intended use, it may be advantageous to either preserve or remove such whitespace. Global options ignore_errors: If set to 'true' or 1, any error condition will result in an empty string being returned rather than an error message. error_category: If an error occurs, specifies the name of a category to include with the error message. The default category is [Category:Errors reported by Module String]. no_category: If set to 'true' or 1, no category will be added if an error is generated. Unit tests for this module are available at Module:String/tests. ]] local str = {} --[[ len This function returns the length of the target string. Usage: {{#invoke:String|len|target_string|}} OR {{#invoke:String|len|s=target_string}} Parameters s: The string whose length to report If invoked using named parameters, Mediawiki will automatically remove any leading or trailing whitespace from the target string. ]] function str.len( frame ) local new_args = str._getParameters( frame.args, {'s'} ) local s = new_args['s'] or '' return mw.ustring.len( s ) end --[[ sub This function returns a substring of the target string at specified indices. Usage: {{#invoke:String|sub|target_string|start_index|end_index}} OR {{#invoke:String|sub|s=target_string|i=start_index|j=end_index}} Parameters s: The string to return a subset of i: The first index of the substring to return, defaults to 1. j: The last index of the string to return, defaults to the last character. The first character of the string is assigned an index of 1. If either i or j is a negative value, it is interpreted the same as selecting a character by counting from the end of the string. Hence, a value of -1 is the same as selecting the last character of the string. If the requested indices are out of range for the given string, an error is reported. ]] function str.sub( frame ) local new_args = str._getParameters( frame.args, { 's', 'i', 'j' } ) local s = new_args['s'] or '' local i = tonumber( new_args['i'] ) or 1 local j = tonumber( new_args['j'] ) or -1 local len = mw.ustring.len( s ) -- Convert negatives for range checking if i < 0 then i = len + i + 1 end if j < 0 then j = len + j + 1 end if i > len or j > len or i < 1 or j < 1 then return str._error( 'String subset index out of range' ) end if j < i then return str._error( 'String subset indices out of order' ) end return mw.ustring.sub( s, i, j ) end --[[ This function implements that features of {{str sub old}} and is kept in order to maintain these older templates. ]] function str.sublength( frame ) local i = tonumber( frame.args.i ) or 0 local len = tonumber( frame.args.len ) return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) ) end --[[ _match This function returns a substring from the source string that matches a specified pattern. It is exported for use in other modules Usage: strmatch = require("Module:String")._match sresult = strmatch( s, pattern, start, match, plain, nomatch ) Parameters s: The string to search pattern: The pattern or string to find within the string start: The index within the source string to start the search. The first character of the string has index 1. Defaults to 1. match: In some cases it may be possible to make multiple matches on a single string. This specifies which match to return, where the first match is match= 1. If a negative number is specified then a match is returned counting from the last match. Hence match = -1 is the same as requesting the last match. Defaults to 1. plain: A flag indicating that the pattern should be understood as plain text. Defaults to false. nomatch: If no match is found, output the "nomatch" value rather than an error. For information on constructing Lua patterns, a form of [regular expression], see: * http://www.lua.org/manual/5.1/manual.html#5.4.1 * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns ]] -- This sub-routine is exported for use in other modules function str._match( s, pattern, start, match_index, plain_flag, nomatch ) if s == '' then return str._error( 'Target string is empty' ) end if pattern == '' then return str._error( 'Pattern string is empty' ) end start = tonumber(start) or 1 if math.abs(start) < 1 or math.abs(start) > mw.ustring.len( s ) then return str._error( 'Requested start is out of range' ) end if match_index == 0 then return str._error( 'Match index is out of range' ) end if plain_flag then pattern = str._escapePattern( pattern ) end local result if match_index == 1 then -- Find first match is simple case result = mw.ustring.match( s, pattern, start ) else if start > 1 then s = mw.ustring.sub( s, start ) end local iterator = mw.ustring.gmatch(s, pattern) if match_index > 0 then -- Forward search for w in iterator do match_index = match_index - 1 if match_index == 0 then result = w break end end else -- Reverse search local result_table = {} local count = 1 for w in iterator do result_table[count] = w count = count + 1 end result = result_table[ count + match_index ] end end if result == nil then if nomatch == nil then return str._error( 'Match not found' ) else return nomatch end else return result end end --[[ match This function returns a substring from the source string that matches a specified pattern. Usage: {{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}} OR {{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index |match=match_number|plain=plain_flag|nomatch=nomatch_output}} Parameters s: The string to search pattern: The pattern or string to find within the string start: The index within the source string to start the search. The first character of the string has index 1. Defaults to 1. match: In some cases it may be possible to make multiple matches on a single string. This specifies which match to return, where the first match is match= 1. If a negative number is specified then a match is returned counting from the last match. Hence match = -1 is the same as requesting the last match. Defaults to 1. plain: A flag indicating that the pattern should be understood as plain text. Defaults to false. nomatch: If no match is found, output the "nomatch" value rather than an error. If invoked using named parameters, Mediawiki will automatically remove any leading or trailing whitespace from each string. In some circumstances this is desirable, in other cases one may want to preserve the whitespace. If the match_number or start_index are out of range for the string being queried, then this function generates an error. An error is also generated if no match is found. If one adds the parameter ignore_errors=true, then the error will be suppressed and an empty string will be returned on any failure. For information on constructing Lua patterns, a form of [regular expression], see: * http://www.lua.org/manual/5.1/manual.html#5.4.1 * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns ]] -- This is the entry point for #invoke:String|match function str.match( frame ) local new_args = str._getParameters( frame.args, {'s', 'pattern', 'start', 'match', 'plain', 'nomatch'} ) local s = new_args['s'] or '' local start = tonumber( new_args['start'] ) or 1 local plain_flag = str._getBoolean( new_args['plain'] or false ) local pattern = new_args['pattern'] or '' local match_index = math.floor( tonumber(new_args['match']) or 1 ) local nomatch = new_args['nomatch'] return str._match( s, pattern, start, match_index, plain_flag, nomatch ) end --[[ pos This function returns a single character from the target string at position pos. Usage: {{#invoke:String|pos|target_string|index_value}} OR {{#invoke:String|pos|target=target_string|pos=index_value}} Parameters target: The string to search pos: The index for the character to return If invoked using named parameters, Mediawiki will automatically remove any leading or trailing whitespace from the target string. In some circumstances this is desirable, in other cases one may want to preserve the whitespace. The first character has an index value of 1. If one requests a negative value, this function will select a character by counting backwards from the end of the string. In other words pos = -1 is the same as asking for the last character. A requested value of zero, or a value greater than the length of the string returns an error. ]] function str.pos( frame ) local new_args = str._getParameters( frame.args, {'target', 'pos'} ) local target_str = new_args['target'] or '' local pos = tonumber( new_args['pos'] ) or 0 if pos == 0 or math.abs(pos) > mw.ustring.len( target_str ) then return str._error( 'String index out of range' ) end return mw.ustring.sub( target_str, pos, pos ) end --[[ str_find This function duplicates the behavior of {{str_find}}, including all of its quirks. This is provided in order to support existing templates, but is NOT RECOMMENDED for new code and templates. New code is recommended to use the "find" function instead. Returns the first index in "source" that is a match to "target". Indexing is 1-based, and the function returns -1 if the "target" string is not present in "source". Important Note: If the "target" string is empty / missing, this function returns a value of "1", which is generally unexpected behavior, and must be accounted for separatetly. ]] function str.str_find( frame ) local new_args = str._getParameters( frame.args, {'source', 'target'} ) local source_str = new_args['source'] or '' local target_str = new_args['target'] or '' if target_str == '' then return 1 end local start = mw.ustring.find( source_str, target_str, 1, true ) if start == nil then start = -1 end return start end --[[ find This function allows one to search for a target string or pattern within another string. Usage: {{#invoke:String|find|source_str|target_string|start_index|plain_flag}} OR {{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}} Parameters source: The string to search target: The string or pattern to find within source start: The index within the source string to start the search, defaults to 1 plain: Boolean flag indicating that target should be understood as plain text and not as a Lua style regular expression, defaults to true If invoked using named parameters, Mediawiki will automatically remove any leading or trailing whitespace from the parameter. In some circumstances this is desirable, in other cases one may want to preserve the whitespace. This function returns the first index >= "start" where "target" can be found within "source". Indices are 1-based. If "target" is not found, then this function returns 0. If either "source" or "target" are missing / empty, this function also returns 0. This function should be safe for UTF-8 strings. ]] function str.find( frame ) local new_args = str._getParameters( frame.args, {'source', 'target', 'start', 'plain' } ) local source_str = new_args['source'] or '' local pattern = new_args['target'] or '' local start_pos = tonumber(new_args['start']) or 1 local plain = new_args['plain'] or true if source_str == '' or pattern == '' then return 0 end plain = str._getBoolean( plain ) local start = mw.ustring.find( source_str, pattern, start_pos, plain ) if start == nil then start = 0 end return start end --[[ replace This function allows one to replace a target string or pattern within another string. Usage: {{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}} OR {{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string| count=replacement_count|plain=plain_flag}} Parameters source: The string to search pattern: The string or pattern to find within source replace: The replacement text count: The number of occurences to replace, defaults to all. plain: Boolean flag indicating that pattern should be understood as plain text and not as a Lua style regular expression, defaults to true ]] function str.replace( frame ) local new_args = str._getParameters( frame.args, {'source', 'pattern', 'replace', 'count', 'plain' } ) local source_str = new_args['source'] or '' local pattern = new_args['pattern'] or '' local replace = new_args['replace'] or '' local count = tonumber( new_args['count'] ) local plain = new_args['plain'] or true if source_str == '' or pattern == '' then return source_str end plain = str._getBoolean( plain ) if plain then pattern = str._escapePattern( pattern ) replace = mw.ustring.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences. end local result if count ~= nil then result = mw.ustring.gsub( source_str, pattern, replace, count ) else result = mw.ustring.gsub( source_str, pattern, replace ) end return result end --[[ simple function to pipe string.rep to templates. ]] function str.rep( frame ) local repetitions = tonumber( frame.args[2] ) if not repetitions then return str._error( 'function rep expects a number as second parameter, received "' .. ( frame.args[2] or '' ) .. '"' ) end return string.rep( frame.args[1] or '', repetitions ) end --[[ escapePattern This function escapes special characters from a Lua string pattern. See [1] for details on how patterns work. [1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns Usage: {{#invoke:String|escapePattern|pattern_string}} Parameters pattern_string: The pattern string to escape. ]] function str.escapePattern( frame ) local pattern_str = frame.args[1] if not pattern_str then return str._error( 'No pattern string specified' ) end local result = str._escapePattern( pattern_str ) return result end --[[ count This function counts the number of occurrences of one string in another. ]] function str.count(frame) local args = str._getParameters(frame.args, {'source', 'pattern', 'plain'}) local source = args.source or '' local pattern = args.pattern or '' local plain = str._getBoolean(args.plain or true) if plain then pattern = str._escapePattern(pattern) end local _, count = mw.ustring.gsub(source, pattern, '') return count end --[[ endswith This function determines whether a string ends with another string. ]] function str.endswith(frame) local args = str._getParameters(frame.args, {'source', 'pattern'}) local source = args.source or '' local pattern = args.pattern or '' if pattern == '' then -- All strings end with the empty string. return "yes" end if mw.ustring.sub(source, -mw.ustring.len(pattern), -1) == pattern then return "yes" else return "" end end --[[ join Join all non empty arguments together; the first argument is the separator. Usage: {{#invoke:String|join|sep|one|two|three}} ]] function str.join(frame) local args = {} local sep for _, v in ipairs( frame.args ) do if sep then if v ~= '' then table.insert(args, v) end else sep = v end end return table.concat( args, sep or '' ) end --[[ Helper function that populates the argument list given that user may need to use a mix of named and unnamed parameters. This is relevant because named parameters are not identical to unnamed parameters due to string trimming, and when dealing with strings we sometimes want to either preserve or remove that whitespace depending on the application. ]] function str._getParameters( frame_args, arg_list ) local new_args = {} local index = 1 local value for _, arg in ipairs( arg_list ) do value = frame_args[arg] if value == nil then value = frame_args[index] index = index + 1 end new_args[arg] = value end return new_args end --[[ Helper function to handle error messages. ]] function str._error( error_str ) local frame = mw.getCurrentFrame() local error_category = frame.args.error_category or 'Errors reported by Module String' local ignore_errors = frame.args.ignore_errors or false local no_category = frame.args.no_category or false if str._getBoolean(ignore_errors) then return '' end local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>' if error_category ~= '' and not str._getBoolean( no_category ) then error_str = '[[Category:' .. error_category .. ']]' .. error_str end return error_str end --[[ Helper Function to interpret boolean strings ]] function str._getBoolean( boolean_str ) local boolean_value if type( boolean_str ) == 'string' then boolean_str = boolean_str:lower() if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0' or boolean_str == '' then boolean_value = false else boolean_value = true end elseif type( boolean_str ) == 'boolean' then boolean_value = boolean_str else error( 'No boolean value found' ) end return boolean_value end --[[ Helper function that escapes all pattern characters so that they will be treated as plain text. ]] function str._escapePattern( pattern_str ) return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ) end return str 2ad0905c56ef4955950b75a8f00974fe82aed5e4 Module:Documentation/config 828 12 94 2023-10-28T01:25:16Z wikipedia>Pppery 0 Split [[Category:Templates sandboxes]] per CfD Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- -- Configuration for Module:Documentation -- -- Here you can set the values of the parameters and messages used in Module:Documentation to -- localise it to your wiki and your language. Unless specified otherwise, values given here -- should be string values. ---------------------------------------------------------------------------------------------------- local cfg = {} -- Do not edit this line. ---------------------------------------------------------------------------------------------------- -- Protection template configuration ---------------------------------------------------------------------------------------------------- -- cfg['protection-reason-edit'] -- The protection reason for edit-protected templates to pass to -- [[Module:Protection banner]]. cfg['protection-reason-edit'] = 'template' --[[ ---------------------------------------------------------------------------------------------------- -- Sandbox notice configuration -- -- On sandbox pages the module can display a template notifying users that the current page is a -- sandbox, and the location of test cases pages, etc. The module decides whether the page is a -- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the -- messages that the notices contains. ---------------------------------------------------------------------------------------------------- --]] -- cfg['sandbox-notice-image'] -- The image displayed in the sandbox notice. cfg['sandbox-notice-image'] = '[[File:Sandbox.svg|50px|alt=|link=]]' --[[ -- cfg['sandbox-notice-pagetype-template'] -- cfg['sandbox-notice-pagetype-module'] -- cfg['sandbox-notice-pagetype-other'] -- The page type of the sandbox page. The message that is displayed depends on the current subject -- namespace. This message is used in either cfg['sandbox-notice-blurb'] or -- cfg['sandbox-notice-diff-blurb']. --]] cfg['sandbox-notice-pagetype-template'] = '[[Wikipedia:Template test cases|template sandbox]] page' cfg['sandbox-notice-pagetype-module'] = '[[Wikipedia:Template test cases|module sandbox]] page' cfg['sandbox-notice-pagetype-other'] = 'sandbox page' --[[ -- cfg['sandbox-notice-blurb'] -- cfg['sandbox-notice-diff-blurb'] -- cfg['sandbox-notice-diff-display'] -- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence -- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page -- type, which is either cfg['sandbox-notice-pagetype-template'], -- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what -- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between -- the sandbox and the main template. The display value of the diff link is set by -- cfg['sandbox-notice-compare-link-display']. --]] cfg['sandbox-notice-blurb'] = 'This is the $1 for $2.' cfg['sandbox-notice-diff-blurb'] = 'This is the $1 for $2 ($3).' cfg['sandbox-notice-compare-link-display'] = 'diff' --[[ -- cfg['sandbox-notice-testcases-blurb'] -- cfg['sandbox-notice-testcases-link-display'] -- cfg['sandbox-notice-testcases-run-blurb'] -- cfg['sandbox-notice-testcases-run-link-display'] -- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit. $1 is a link to the test cases page. -- cfg['sandbox-notice-testcases-link-display'] is the display value for that link. -- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test -- cases page, and $2 is a link to the page to run it. -- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test -- cases. --]] cfg['sandbox-notice-testcases-blurb'] = 'See also the companion subpage for $1.' cfg['sandbox-notice-testcases-link-display'] = 'test cases' cfg['sandbox-notice-testcases-run-blurb'] = 'See also the companion subpage for $1 ($2).' cfg['sandbox-notice-testcases-run-link-display'] = 'run' -- cfg['sandbox-category'] - A category to add to all template sandboxes. -- cfg['module-sandbox-category'] - A category to add to all module sandboxes. -- cfg['module-sandbox-category'] - A category to add to all sandboxe not in templates or modules. cfg['sandbox-category'] = 'Template sandboxes' cfg['module-sandbox-category'] = 'Module sandboxes' cfg['other-sandbox-category'] = 'Sandboxes outside of template or module namespace' ---------------------------------------------------------------------------------------------------- -- Start box configuration ---------------------------------------------------------------------------------------------------- -- cfg['documentation-icon-wikitext'] -- The wikitext for the icon shown at the top of the template. cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]' -- cfg['template-namespace-heading'] -- The heading shown in the template namespace. cfg['template-namespace-heading'] = 'Template documentation' -- cfg['module-namespace-heading'] -- The heading shown in the module namespace. cfg['module-namespace-heading'] = 'Module documentation' -- cfg['file-namespace-heading'] -- The heading shown in the file namespace. cfg['file-namespace-heading'] = 'Summary' -- cfg['other-namespaces-heading'] -- The heading shown in other namespaces. cfg['other-namespaces-heading'] = 'Documentation' -- cfg['view-link-display'] -- The text to display for "view" links. cfg['view-link-display'] = 'view' -- cfg['edit-link-display'] -- The text to display for "edit" links. cfg['edit-link-display'] = 'edit' -- cfg['history-link-display'] -- The text to display for "history" links. cfg['history-link-display'] = 'history' -- cfg['purge-link-display'] -- The text to display for "purge" links. cfg['purge-link-display'] = 'purge' -- cfg['create-link-display'] -- The text to display for "create" links. cfg['create-link-display'] = 'create' ---------------------------------------------------------------------------------------------------- -- Link box (end box) configuration ---------------------------------------------------------------------------------------------------- -- cfg['transcluded-from-blurb'] -- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page. cfg['transcluded-from-blurb'] = 'The above [[Wikipedia:Template documentation|documentation]] is [[Help:Transclusion|transcluded]] from $1.' --[[ -- cfg['create-module-doc-blurb'] -- Notice displayed in the module namespace when the documentation subpage does not exist. -- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the -- display cfg['create-link-display']. --]] cfg['create-module-doc-blurb'] = 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].' ---------------------------------------------------------------------------------------------------- -- Experiment blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['experiment-blurb-template'] -- cfg['experiment-blurb-module'] -- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages. -- It is only shown in the template and module namespaces. With the default English settings, it -- might look like this: -- -- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. -- -- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links. -- -- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending -- on what namespace we are in. -- -- Parameters: -- -- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display']) -- -- If the sandbox doesn't exist, it is in the format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display']) -- -- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload'] -- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display'] -- loads a default edit summary of cfg['mirror-edit-summary']. -- -- $2 is a link to the test cases page. If the test cases page exists, it is in the following format: -- -- cfg['testcases-link-display'] (cfg['testcases-edit-link-display'] | cfg['testcases-run-link-display']) -- -- If the test cases page doesn't exist, it is in the format: -- -- cfg['testcases-link-display'] (cfg['testcases-create-link-display']) -- -- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the -- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current -- namespace. --]] cfg['experiment-blurb-template'] = "Editors can experiment in this template's $1 and $2 pages." cfg['experiment-blurb-module'] = "Editors can experiment in this module's $1 and $2 pages." ---------------------------------------------------------------------------------------------------- -- Sandbox link configuration ---------------------------------------------------------------------------------------------------- -- cfg['sandbox-subpage'] -- The name of the template subpage typically used for sandboxes. cfg['sandbox-subpage'] = 'sandbox' -- cfg['template-sandbox-preload'] -- Preload file for template sandbox pages. cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox' -- cfg['module-sandbox-preload'] -- Preload file for Lua module sandbox pages. cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox' -- cfg['sandbox-link-display'] -- The text to display for "sandbox" links. cfg['sandbox-link-display'] = 'sandbox' -- cfg['sandbox-edit-link-display'] -- The text to display for sandbox "edit" links. cfg['sandbox-edit-link-display'] = 'edit' -- cfg['sandbox-create-link-display'] -- The text to display for sandbox "create" links. cfg['sandbox-create-link-display'] = 'create' -- cfg['compare-link-display'] -- The text to display for "compare" links. cfg['compare-link-display'] = 'diff' -- cfg['mirror-edit-summary'] -- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the -- template page. cfg['mirror-edit-summary'] = 'Create sandbox version of $1' -- cfg['mirror-link-display'] -- The text to display for "mirror" links. cfg['mirror-link-display'] = 'mirror' -- cfg['mirror-link-preload'] -- The page to preload when a user clicks the "mirror" link. cfg['mirror-link-preload'] = 'Template:Documentation/mirror' ---------------------------------------------------------------------------------------------------- -- Test cases link configuration ---------------------------------------------------------------------------------------------------- -- cfg['testcases-subpage'] -- The name of the template subpage typically used for test cases. cfg['testcases-subpage'] = 'testcases' -- cfg['template-testcases-preload'] -- Preload file for template test cases pages. cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases' -- cfg['module-testcases-preload'] -- Preload file for Lua module test cases pages. cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases' -- cfg['testcases-link-display'] -- The text to display for "testcases" links. cfg['testcases-link-display'] = 'testcases' -- cfg['testcases-edit-link-display'] -- The text to display for test cases "edit" links. cfg['testcases-edit-link-display'] = 'edit' -- cfg['testcases-run-link-display'] -- The text to display for test cases "run" links. cfg['testcases-run-link-display'] = 'run' -- cfg['testcases-create-link-display'] -- The text to display for test cases "create" links. cfg['testcases-create-link-display'] = 'create' ---------------------------------------------------------------------------------------------------- -- Add categories blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['add-categories-blurb'] -- Text to direct users to add categories to the /doc subpage. Not used if the "content" or -- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a -- link to the /doc subpage with a display value of cfg['doc-link-display']. --]] cfg['add-categories-blurb'] = 'Add categories to the $1 subpage.' -- cfg['doc-link-display'] -- The text to display when linking to the /doc subpage. cfg['doc-link-display'] = '/doc' ---------------------------------------------------------------------------------------------------- -- Subpages link configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['subpages-blurb'] -- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a -- display value of cfg['subpages-link-display']. In the English version this blurb is simply -- the link followed by a period, and the link display provides the actual text. --]] cfg['subpages-blurb'] = '$1.' --[[ -- cfg['subpages-link-display'] -- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'], -- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in -- the template namespace, the module namespace, or another namespace. --]] cfg['subpages-link-display'] = 'Subpages of this $1' -- cfg['template-pagetype'] -- The pagetype to display for template pages. cfg['template-pagetype'] = 'template' -- cfg['module-pagetype'] -- The pagetype to display for Lua module pages. cfg['module-pagetype'] = 'module' -- cfg['default-pagetype'] -- The pagetype to display for pages other than templates or Lua modules. cfg['default-pagetype'] = 'page' ---------------------------------------------------------------------------------------------------- -- Doc link configuration ---------------------------------------------------------------------------------------------------- -- cfg['doc-subpage'] -- The name of the subpage typically used for documentation pages. cfg['doc-subpage'] = 'doc' -- cfg['docpage-preload'] -- Preload file for template documentation pages in all namespaces. cfg['docpage-preload'] = 'Template:Documentation/preload' -- cfg['module-preload'] -- Preload file for Lua module documentation pages. cfg['module-preload'] = 'Template:Documentation/preload-module-doc' ---------------------------------------------------------------------------------------------------- -- HTML and CSS configuration ---------------------------------------------------------------------------------------------------- -- cfg['templatestyles'] -- The name of the TemplateStyles page where CSS is kept. -- Sandbox CSS will be at Module:Documentation/sandbox/styles.css when needed. cfg['templatestyles'] = 'Module:Documentation/styles.css' -- cfg['container'] -- Class which can be used to set flex or grid CSS on the -- two child divs documentation and documentation-metadata cfg['container'] = 'documentation-container' -- cfg['main-div-classes'] -- Classes added to the main HTML "div" tag. cfg['main-div-classes'] = 'documentation' -- cfg['main-div-heading-class'] -- Class for the main heading for templates and modules and assoc. talk spaces cfg['main-div-heading-class'] = 'documentation-heading' -- cfg['start-box-class'] -- Class for the start box cfg['start-box-class'] = 'documentation-startbox' -- cfg['start-box-link-classes'] -- Classes used for the [view][edit][history] or [create] links in the start box. -- mw-editsection-like is per [[Wikipedia:Village pump (technical)/Archive 117]] cfg['start-box-link-classes'] = 'mw-editsection-like plainlinks' -- cfg['end-box-class'] -- Class for the end box. cfg['end-box-class'] = 'documentation-metadata' -- cfg['end-box-plainlinks'] -- Plainlinks cfg['end-box-plainlinks'] = 'plainlinks' -- cfg['toolbar-class'] -- Class added for toolbar links. cfg['toolbar-class'] = 'documentation-toolbar' -- cfg['clear'] -- Just used to clear things. cfg['clear'] = 'documentation-clear' ---------------------------------------------------------------------------------------------------- -- Tracking category configuration ---------------------------------------------------------------------------------------------------- -- cfg['display-strange-usage-category'] -- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage -- or a /testcases subpage. This should be a boolean value (either true or false). cfg['display-strange-usage-category'] = true -- cfg['strange-usage-category'] -- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a -- /doc subpage or a /testcases subpage. cfg['strange-usage-category'] = 'Wikipedia pages with strange ((documentation)) usage' --[[ ---------------------------------------------------------------------------------------------------- -- End configuration -- -- Don't edit anything below this line. ---------------------------------------------------------------------------------------------------- --]] return cfg 56b6127664e31128dea1cecf2e392cf9313df6a3 Template:Stub/doc 10 51 112 2023-11-10T06:24:42Z wikipedia>DB1729 0 Reverted 1 edit by [[Special:Contributions/2601:188:CE01:F1D0:D52E:7D60:51E:70D0|2601:188:CE01:F1D0:D52E:7D60:51E:70D0]] ([[User talk:2601:188:CE01:F1D0:D52E:7D60:51E:70D0|talk]]) to last revision by Pols12 wikitext text/x-wiki {{documentation subpage}} <!-- Intentionally blank: interlanguage links for [[Template:Stub]] are now held at [[d:Special:ItemByTitle/enwiki/Template:Stub]]. --> ===TemplateData=== {{TemplateData header}} <templatedata> { "description": "Standard template used for sorting articles into stubs.", "params": {}, "format": "inline" } </templatedata> 4e08e86ecdef137b8a8a26bf6766217f8fc8e0ce Module:Message box/configuration 828 58 128 2023-11-24T02:41:46Z wikipedia>Pppery 0 Per edit request Scribunto text/plain -------------------------------------------------------------------------------- -- Message box configuration -- -- -- -- This module contains configuration data for [[Module:Message box]]. -- -------------------------------------------------------------------------------- return { ambox = { types = { speedy = { class = 'ambox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'ambox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'ambox-content', image = 'Ambox important.svg' }, style = { class = 'ambox-style', image = 'Edit-clear.svg' }, move = { class = 'ambox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'ambox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, notice = { class = 'ambox-notice', image = 'Information icon4.svg' } }, default = 'notice', allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'}, allowSmall = true, smallParam = 'left', smallClass = 'mbox-small-left', substCheck = true, classes = {'metadata', 'ambox'}, imageEmptyCell = true, imageCheckBlank = true, imageSmallSize = '20x20px', imageCellDiv = true, useCollapsibleTextFields = true, imageRightNone = true, sectionDefault = 'article', allowMainspaceCategories = true, templateCategory = 'Article message templates', templateCategoryRequireName = true, templateErrorCategory = 'Article message templates with missing parameters', templateErrorParamsToCheck = {'issue', 'fix', 'subst'}, removalNotice = '<small>[[Help:Maintenance template removal|Learn how and when to remove this template message]]</small>', templatestyles = 'Module:Message box/ambox.css' }, cmbox = { types = { speedy = { class = 'cmbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'cmbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'cmbox-content', image = 'Ambox important.svg' }, style = { class = 'cmbox-style', image = 'Edit-clear.svg' }, move = { class = 'cmbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'cmbox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, notice = { class = 'cmbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'cmbox'}, imageEmptyCell = true, templatestyles = 'Module:Message box/cmbox.css' }, fmbox = { types = { warning = { class = 'fmbox-warning', image = 'Ambox warning pn.svg' }, editnotice = { class = 'fmbox-editnotice', image = 'Information icon4.svg' }, system = { class = 'fmbox-system', image = 'Information icon4.svg' } }, default = 'system', showInvalidTypeError = true, classes = {'fmbox'}, imageEmptyCell = false, imageRightNone = false, templatestyles = 'Module:Message box/fmbox.css' }, imbox = { types = { speedy = { class = 'imbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'imbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'imbox-content', image = 'Ambox important.svg' }, style = { class = 'imbox-style', image = 'Edit-clear.svg' }, move = { class = 'imbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'imbox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, license = { class = 'imbox-license licensetpl', image = 'Imbox-license.svg' }, ["license-related"] = { class = 'imbox-license', image = 'Imbox-license.svg' }, featured = { class = 'imbox-featured', image = 'Cscr-featured.svg', imageNeedsLink = true }, notice = { class = 'imbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'imbox'}, imageEmptyCell = true, below = true, templateCategory = 'File message boxes', templatestyles = 'Module:Message box/imbox.css' }, ombox = { types = { speedy = { class = 'ombox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'ombox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'ombox-content', image = 'Ambox important.svg' }, style = { class = 'ombox-style', image = 'Edit-clear.svg' }, move = { class = 'ombox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'ombox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, notice = { class = 'ombox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'ombox'}, allowSmall = true, imageEmptyCell = true, imageRightNone = true, templatestyles = 'Module:Message box/ombox.css' }, tmbox = { types = { speedy = { class = 'tmbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'tmbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'tmbox-content', image = 'Ambox important.svg' }, style = { class = 'tmbox-style', image = 'Edit-clear.svg' }, move = { class = 'tmbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'tmbox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, notice = { class = 'tmbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'tmbox'}, allowSmall = true, imageRightNone = true, imageEmptyCell = true, templateCategory = 'Talk message boxes', templatestyles = 'Module:Message box/tmbox.css' } } ccb6bdf2868087b6833d203307f2f6a92b3b0a01 Template:Template parameter usage 10 47 104 2023-11-27T06:57:32Z wikipedia>Sdkb 0 Partial revert of [[User:SUM1]]'s edit [[Special:Diff/1039918972]] per [[WP:CLICKHERE]] wikitext text/x-wiki {{#switch:{{{label|}}} |=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|S|s}}ee a monthly parameter usage report] for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|this template}} in articles{{#ifeq:{{yesno-no|{{{based}}}}}|yes|&#32;based on {{#if:{{{1|}}}|its|this}} TemplateData}}. |None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|P|p}}arameter usage report]{{#ifeq:{{yesno-no|{{{based}}}}}|yes|&#32;based on {{#if:{{{1|}}}|its|this}} TemplateData}} |for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|P|p}}arameter usage report] for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|[[Template:{{ROOTPAGENAME}}]]}}{{#ifeq:{{yesno-no|{{{based}}}}}|yes|&#32;based on {{#if:{{{1|}}}|its|this}} TemplateData}}. |#default=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{{label|}}}]{{#ifeq:{{yesno-no|{{{based}}}}}|yes|&#32;based on {{#if:{{{1|}}}|its|this}} TemplateData}} }}<noinclude> {{documentation}} </noinclude> 83e574f5e031df639a2cdcef5b91d6b1094ae648 Template:TemplateData header 10 46 102 2023-12-01T11:27:04Z wikipedia>Gonnym 0 fix website link if |1= is used wikitext text/x-wiki <div class="templatedata-header">{{#if:{{{noheader|}}}|<!-- noheader: -->{{Template parameter usage|{{{1|{{BASEPAGENAME}}}}}|based=y}}|<!-- +header: -->This is the {{#if:{{{nolink|}}}|<!-- +header, nolink TD -->TemplateData|<!-- +header, +link [[TD]]; DEFAULT: -->[[Wikipedia:TemplateData|TemplateData]]}}<!-- e.o. #if:nolink; DEFAULT: --> for this template used by [[mw:Extension:TemplateWizard|TemplateWizard]], [[Wikipedia:VisualEditor|VisualEditor]] and other tools. {{Template parameter usage|{{{1|{{BASEPAGENAME}}}}}|based=y}}<!-- e.o. #if:noheader -->}} '''TemplateData for {{{1|{{BASEPAGENAME}}}}}''' </div><includeonly><!-- check parameters -->{{#invoke:Check for unknown parameters|check |unknown={{template other|1=[[Category:Pages using TemplateData header with unknown parameters|_VALUE_]]}} |template=Template:TemplateData header |1 |nolink |noheader |preview=<div class="error" style="font-weight:normal">Unknown parameter '_VALUE_' in [[Template:TemplateData header]].</div> }}<!-- -->{{template other|{{sandbox other|| [[Category:Templates using TemplateData]] }}}}</includeonly><!-- --><noinclude>{{Documentation}}</noinclude> 748b89c815a11e78b365c5617460ea569f3f96cb Module:Message box/configuration/doc 828 66 148 2023-12-04T15:16:19Z wikipedia>Cjse23 0 Reverted edits by [[Special:Contributions/158.99.4.120|158.99.4.120]] ([[User talk:158.99.4.120|talk]]) ([[WP:HG|HG]]) (3.4.12) wikitext text/x-wiki {{Used in system}} {{Module rating|protected}} Configuration for [[Module:Message box]]. ffb793a2e927e8589f3a9b2cc287b2d4584e7afb Module:Documentation 828 8 92 2024-01-07T08:09:04Z wikipedia>DannyS712 0 remove unneeded return variables (if this breaks anything feel free to revert without discussing with me first) Scribunto text/plain -- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs -- Get the config table. local cfg = mw.loadData('Module:Documentation/config') local p = {} -- Often-used functions. local ugsub = mw.ustring.gsub local format = mw.ustring.format ---------------------------------------------------------------------------- -- Helper functions -- -- These are defined as local functions, but are made available in the p -- table for testing purposes. ---------------------------------------------------------------------------- local function message(cfgKey, valArray, expectType) --[[ -- Gets a message from the cfg table and formats it if appropriate. -- The function raises an error if the value from the cfg table is not -- of the type expectType. The default type for expectType is 'string'. -- If the table valArray is present, strings such as $1, $2 etc. in the -- message are substituted with values from the table keys [1], [2] etc. -- For example, if the message "foo-message" had the value 'Foo $2 bar $1.', -- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz." --]] local msg = cfg[cfgKey] expectType = expectType or 'string' if type(msg) ~= expectType then error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2) end if not valArray then return msg end local function getMessageVal(match) match = tonumber(match) return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4) end return ugsub(msg, '$([1-9][0-9]*)', getMessageVal) end p.message = message local function makeWikilink(page, display) if display then return format('[[%s|%s]]', page, display) else return format('[[%s]]', page) end end p.makeWikilink = makeWikilink local function makeCategoryLink(cat, sort) local catns = mw.site.namespaces[14].name return makeWikilink(catns .. ':' .. cat, sort) end p.makeCategoryLink = makeCategoryLink local function makeUrlLink(url, display) return format('[%s %s]', url, display) end p.makeUrlLink = makeUrlLink local function makeToolbar(...) local ret = {} local lim = select('#', ...) if lim < 1 then return nil end for i = 1, lim do ret[#ret + 1] = select(i, ...) end -- 'documentation-toolbar' return format( '<span class="%s">(%s)</span>', message('toolbar-class'), table.concat(ret, ' &#124; ') ) end p.makeToolbar = makeToolbar ---------------------------------------------------------------------------- -- Argument processing ---------------------------------------------------------------------------- local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame, { valueFunc = function (key, value) if type(value) == 'string' then value = value:match('^%s*(.-)%s*$') -- Remove whitespace. if key == 'heading' or value ~= '' then return value else return nil end else return value end end }) return p[funcName](args) end end ---------------------------------------------------------------------------- -- Entry points ---------------------------------------------------------------------------- function p.nonexistent(frame) if mw.title.getCurrentTitle().subpageText == 'testcases' then return frame:expandTemplate{title = 'module test cases notice'} else return p.main(frame) end end p.main = makeInvokeFunc('_main') function p._main(args) --[[ -- This function defines logic flow for the module. -- @args - table of arguments passed by the user --]] local env = p.getEnvironment(args) local root = mw.html.create() root :wikitext(p._getModuleWikitext(args, env)) :wikitext(p.protectionTemplate(env)) :wikitext(p.sandboxNotice(args, env)) :tag('div') -- 'documentation-container' :addClass(message('container')) :attr('role', 'complementary') :attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil) :attr('aria-label', args.heading == '' and 'Documentation' or nil) :newline() :tag('div') -- 'documentation' :addClass(message('main-div-classes')) :newline() :wikitext(p._startBox(args, env)) :wikitext(p._content(args, env)) :tag('div') -- 'documentation-clear' :addClass(message('clear')) :done() :newline() :done() :wikitext(p._endBox(args, env)) :done() :wikitext(p.addTrackingCategories(env)) -- 'Module:Documentation/styles.css' return mw.getCurrentFrame():extensionTag ( 'templatestyles', '', {src=cfg['templatestyles'] }) .. tostring(root) end ---------------------------------------------------------------------------- -- Environment settings ---------------------------------------------------------------------------- function p.getEnvironment(args) --[[ -- Returns a table with information about the environment, including title -- objects and other namespace- or path-related data. -- @args - table of arguments passed by the user -- -- Title objects include: -- env.title - the page we are making documentation for (usually the current title) -- env.templateTitle - the template (or module, file, etc.) -- env.docTitle - the /doc subpage. -- env.sandboxTitle - the /sandbox subpage. -- env.testcasesTitle - the /testcases subpage. -- -- Data includes: -- env.protectionLevels - the protection levels table of the title object. -- env.subjectSpace - the number of the title's subject namespace. -- env.docSpace - the number of the namespace the title puts its documentation in. -- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace. -- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template. -- -- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value -- returned will be nil. --]] local env, envFuncs = {}, {} -- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value -- returned by that function is memoized in the env table so that we don't call any of the functions -- more than once. (Nils won't be memoized.) setmetatable(env, { __index = function (t, key) local envFunc = envFuncs[key] if envFunc then local success, val = pcall(envFunc) if success then env[key] = val -- Memoise the value. return val end end return nil end }) function envFuncs.title() -- The title object for the current page, or a test page passed with args.page. local title local titleArg = args.page if titleArg then title = mw.title.new(titleArg) else title = mw.title.getCurrentTitle() end return title end function envFuncs.templateTitle() --[[ -- The template (or module, etc.) title object. -- Messages: -- 'sandbox-subpage' --> 'sandbox' -- 'testcases-subpage' --> 'testcases' --]] local subjectSpace = env.subjectSpace local title = env.title local subpage = title.subpageText if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then return mw.title.makeTitle(subjectSpace, title.baseText) else return mw.title.makeTitle(subjectSpace, title.text) end end function envFuncs.docTitle() --[[ -- Title object of the /doc subpage. -- Messages: -- 'doc-subpage' --> 'doc' --]] local title = env.title local docname = args[1] -- User-specified doc page. local docpage if docname then docpage = docname else docpage = env.docpageBase .. '/' .. message('doc-subpage') end return mw.title.new(docpage) end function envFuncs.sandboxTitle() --[[ -- Title object for the /sandbox subpage. -- Messages: -- 'sandbox-subpage' --> 'sandbox' --]] return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage')) end function envFuncs.testcasesTitle() --[[ -- Title object for the /testcases subpage. -- Messages: -- 'testcases-subpage' --> 'testcases' --]] return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage')) end function envFuncs.protectionLevels() -- The protection levels table of the title object. return env.title.protectionLevels end function envFuncs.subjectSpace() -- The subject namespace number. return mw.site.namespaces[env.title.namespace].subject.id end function envFuncs.docSpace() -- The documentation namespace number. For most namespaces this is the -- same as the subject namespace. However, pages in the Article, File, -- MediaWiki or Category namespaces must have their /doc, /sandbox and -- /testcases pages in talk space. local subjectSpace = env.subjectSpace if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then return subjectSpace + 1 else return subjectSpace end end function envFuncs.docpageBase() -- The base page of the /doc, /sandbox, and /testcases subpages. -- For some namespaces this is the talk page, rather than the template page. local templateTitle = env.templateTitle local docSpace = env.docSpace local docSpaceText = mw.site.namespaces[docSpace].name -- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon. return docSpaceText .. ':' .. templateTitle.text end function envFuncs.compareUrl() -- Diff link between the sandbox and the main template using [[Special:ComparePages]]. local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle if templateTitle.exists and sandboxTitle.exists then local compareUrl = mw.uri.canonicalUrl( 'Special:ComparePages', { page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} ) return tostring(compareUrl) else return nil end end return env end ---------------------------------------------------------------------------- -- Auxiliary templates ---------------------------------------------------------------------------- p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext') function p._getModuleWikitext(args, env) local currentTitle = mw.title.getCurrentTitle() if currentTitle.contentModel ~= 'Scribunto' then return end pcall(require, currentTitle.prefixedText) -- if it fails, we don't care local moduleWikitext = package.loaded["Module:Module wikitext"] if moduleWikitext then return moduleWikitext.main() end end function p.sandboxNotice(args, env) --[=[ -- Generates a sandbox notice for display above sandbox pages. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-notice-image' --> '[[File:Sandbox.svg|50px|alt=|link=]]' -- 'sandbox-notice-blurb' --> 'This is the $1 for $2.' -- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).' -- 'sandbox-notice-pagetype-template' --> '[[Wikipedia:Template test cases|template sandbox]] page' -- 'sandbox-notice-pagetype-module' --> '[[Wikipedia:Template test cases|module sandbox]] page' -- 'sandbox-notice-pagetype-other' --> 'sandbox page' -- 'sandbox-notice-compare-link-display' --> 'diff' -- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.' -- 'sandbox-notice-testcases-link-display' --> 'test cases' -- 'sandbox-category' --> 'Template sandboxes' -- 'module-sandbox-category' --> 'Module sandboxes' -- 'other-sandbox-category' --> 'Sandboxes outside of template or module namespace' --]=] local title = env.title local sandboxTitle = env.sandboxTitle local templateTitle = env.templateTitle local subjectSpace = env.subjectSpace if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then return nil end -- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text". local omargs = {} omargs.image = message('sandbox-notice-image') -- Get the text. We start with the opening blurb, which is something like -- "This is the template sandbox for [[Template:Foo]] (diff)." local text = '' local pagetype, sandboxCat if subjectSpace == 10 then pagetype = message('sandbox-notice-pagetype-template') sandboxCat = message('sandbox-category') elseif subjectSpace == 828 then pagetype = message('sandbox-notice-pagetype-module') sandboxCat = message('module-sandbox-category') else pagetype = message('sandbox-notice-pagetype-other') sandboxCat = message('other-sandbox-category') end local templateLink = makeWikilink(templateTitle.prefixedText) local compareUrl = env.compareUrl if compareUrl then local compareDisplay = message('sandbox-notice-compare-link-display') local compareLink = makeUrlLink(compareUrl, compareDisplay) text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink}) else text = text .. message('sandbox-notice-blurb', {pagetype, templateLink}) end -- Get the test cases page blurb if the page exists. This is something like -- "See also the companion subpage for [[Template:Foo/testcases|test cases]]." local testcasesTitle = env.testcasesTitle if testcasesTitle and testcasesTitle.exists then if testcasesTitle.contentModel == "Scribunto" then local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink}) else local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink}) end end -- Add the sandbox to the sandbox category. omargs.text = text .. makeCategoryLink(sandboxCat) -- 'documentation-clear' return '<div class="' .. message('clear') .. '"></div>' .. require('Module:Message box').main('ombox', omargs) end function p.protectionTemplate(env) -- Generates the padlock icon in the top right. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'protection-template' --> 'pp-template' -- 'protection-template-args' --> {docusage = 'yes'} local protectionLevels = env.protectionLevels if not protectionLevels then return nil end local editProt = protectionLevels.edit and protectionLevels.edit[1] local moveProt = protectionLevels.move and protectionLevels.move[1] if editProt then -- The page is edit-protected. return require('Module:Protection banner')._main{ message('protection-reason-edit'), small = true } elseif moveProt and moveProt ~= 'autoconfirmed' then -- The page is move-protected but not edit-protected. Exclude move -- protection with the level "autoconfirmed", as this is equivalent to -- no move protection at all. return require('Module:Protection banner')._main{ action = 'move', small = true } else return nil end end ---------------------------------------------------------------------------- -- Start box ---------------------------------------------------------------------------- p.startBox = makeInvokeFunc('_startBox') function p._startBox(args, env) --[[ -- This function generates the start box. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make -- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox -- which generate the box HTML. --]] env = env or p.getEnvironment(args) local links local content = args.content if not content or args[1] then -- No need to include the links if the documentation is on the template page itself. local linksData = p.makeStartBoxLinksData(args, env) if linksData then links = p.renderStartBoxLinks(linksData) end end -- Generate the start box html. local data = p.makeStartBoxData(args, env, links) if data then return p.renderStartBox(data) else -- User specified no heading. return nil end end function p.makeStartBoxLinksData(args, env) --[[ -- Does initial processing of data to make the [view] [edit] [history] [purge] links. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'view-link-display' --> 'view' -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'purge-link-display' --> 'purge' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'docpage-preload' --> 'Template:Documentation/preload' -- 'create-link-display' --> 'create' --]] local subjectSpace = env.subjectSpace local title = env.title local docTitle = env.docTitle if not title or not docTitle then return nil end if docTitle.isRedirect then docTitle = docTitle.redirectTarget end -- Create link if /doc doesn't exist. local preload = args.preload if not preload then if subjectSpace == 828 then -- Module namespace preload = message('module-preload') else preload = message('docpage-preload') end end return { title = title, docTitle = docTitle, -- View, display, edit, and purge links if /doc exists. viewLinkDisplay = message('view-link-display'), editLinkDisplay = message('edit-link-display'), historyLinkDisplay = message('history-link-display'), purgeLinkDisplay = message('purge-link-display'), preload = preload, createLinkDisplay = message('create-link-display') } end function p.renderStartBoxLinks(data) --[[ -- Generates the [view][edit][history][purge] or [create][purge] links from the data table. -- @data - a table of data generated by p.makeStartBoxLinksData --]] local docTitle = data.docTitle -- yes, we do intend to purge the template page on which the documentation appears local purgeLink = makeWikilink("Special:Purge/" .. data.title.prefixedText, data.purgeLinkDisplay) if docTitle.exists then local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay) local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, data.editLinkDisplay) local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, data.historyLinkDisplay) return "&#91;" .. viewLink .. "&#93; &#91;" .. editLink .. "&#93; &#91;" .. historyLink .. "&#93; &#91;" .. purgeLink .. "&#93;" else local createLink = makeUrlLink(docTitle:canonicalUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay) return "&#91;" .. createLink .. "&#93; &#91;" .. purgeLink .. "&#93;" end return ret end function p.makeStartBoxData(args, env, links) --[=[ -- Does initial processing of data to pass to the start-box render function, p.renderStartBox. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error. -- -- Messages: -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]' -- 'template-namespace-heading' --> 'Template documentation' -- 'module-namespace-heading' --> 'Module documentation' -- 'file-namespace-heading' --> 'Summary' -- 'other-namespaces-heading' --> 'Documentation' -- 'testcases-create-link-display' --> 'create' --]=] local subjectSpace = env.subjectSpace if not subjectSpace then -- Default to an "other namespaces" namespace, so that we get at least some output -- if an error occurs. subjectSpace = 2 end local data = {} -- Heading local heading = args.heading -- Blank values are not removed. if heading == '' then -- Don't display the start box if the heading arg is defined but blank. return nil end if heading then data.heading = heading elseif subjectSpace == 10 then -- Template namespace data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading') elseif subjectSpace == 828 then -- Module namespace data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading') elseif subjectSpace == 6 then -- File namespace data.heading = message('file-namespace-heading') else data.heading = message('other-namespaces-heading') end -- Heading CSS local headingStyle = args['heading-style'] if headingStyle then data.headingStyleText = headingStyle else -- 'documentation-heading' data.headingClass = message('main-div-heading-class') end -- Data for the [view][edit][history][purge] or [create] links. if links then -- 'mw-editsection-like plainlinks' data.linksClass = message('start-box-link-classes') data.links = links end return data end function p.renderStartBox(data) -- Renders the start box html. -- @data - a table of data generated by p.makeStartBoxData. local sbox = mw.html.create('div') sbox -- 'documentation-startbox' :addClass(message('start-box-class')) :newline() :tag('span') :addClass(data.headingClass) :attr('id', 'documentation-heading') :cssText(data.headingStyleText) :wikitext(data.heading) local links = data.links if links then sbox:tag('span') :addClass(data.linksClass) :attr('id', data.linksId) :wikitext(links) end return tostring(sbox) end ---------------------------------------------------------------------------- -- Documentation content ---------------------------------------------------------------------------- p.content = makeInvokeFunc('_content') function p._content(args, env) -- Displays the documentation contents -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment env = env or p.getEnvironment(args) local docTitle = env.docTitle local content = args.content if not content and docTitle and docTitle.exists then content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText} end -- The line breaks below are necessary so that "=== Headings ===" at the start and end -- of docs are interpreted correctly. return '\n' .. (content or '') .. '\n' end p.contentTitle = makeInvokeFunc('_contentTitle') function p._contentTitle(args, env) env = env or p.getEnvironment(args) local docTitle = env.docTitle if not args.content and docTitle and docTitle.exists then return docTitle.prefixedText else return '' end end ---------------------------------------------------------------------------- -- End box ---------------------------------------------------------------------------- p.endBox = makeInvokeFunc('_endBox') function p._endBox(args, env) --[=[ -- This function generates the end box (also known as the link box). -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- --]=] -- Get environment data. env = env or p.getEnvironment(args) local subjectSpace = env.subjectSpace local docTitle = env.docTitle if not subjectSpace or not docTitle then return nil end -- Check whether we should output the end box at all. Add the end -- box by default if the documentation exists or if we are in the -- user, module or template namespaces. local linkBox = args['link box'] if linkBox == 'off' or not ( docTitle.exists or subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 ) then return nil end -- Assemble the link box. local text = '' if linkBox then text = text .. linkBox else text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]." if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then -- We are in the user, template or module namespaces. -- Add sandbox and testcases links. -- "Editors can experiment in this template's sandbox and testcases pages." text = text .. (p.makeExperimentBlurb(args, env) or '') .. '<br />' if not args.content and not args[1] then -- "Please add categories to the /doc subpage." -- Don't show this message with inline docs or with an explicitly specified doc page, -- as then it is unclear where to add the categories. text = text .. (p.makeCategoriesBlurb(args, env) or '') end text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template" end end local box = mw.html.create('div') -- 'documentation-metadata' box:attr('role', 'note') :addClass(message('end-box-class')) -- 'plainlinks' :addClass(message('end-box-plainlinks')) :wikitext(text) :done() return '\n' .. tostring(box) end function p.makeDocPageBlurb(args, env) --[=[ -- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)". -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'transcluded-from-blurb' --> -- 'The above [[Wikipedia:Template documentation|documentation]] -- is [[Help:Transclusion|transcluded]] from $1.' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'create-link-display' --> 'create' -- 'create-module-doc-blurb' --> -- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].' --]=] local docTitle = env.docTitle if not docTitle then return nil end if docTitle.exists then -- /doc exists; link to it. local docLink = makeWikilink(docTitle.prefixedText) local editDisplay = message('edit-link-display') local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, editDisplay) local historyDisplay = message('history-link-display') local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, historyDisplay) return message('transcluded-from-blurb', {docLink}) .. ' ' .. makeToolbar(editLink, historyLink) .. '<br />' elseif env.subjectSpace == 828 then -- /doc does not exist; ask to create it. local createUrl = docTitle:canonicalUrl{action = 'edit', preload = message('module-preload')} local createDisplay = message('create-link-display') local createLink = makeUrlLink(createUrl, createDisplay) return message('create-module-doc-blurb', {createLink}) .. '<br />' end end function p.makeExperimentBlurb(args, env) --[[ -- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-link-display' --> 'sandbox' -- 'sandbox-edit-link-display' --> 'edit' -- 'compare-link-display' --> 'diff' -- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'sandbox-create-link-display' --> 'create' -- 'mirror-edit-summary' --> 'Create sandbox version of $1' -- 'mirror-link-display' --> 'mirror' -- 'mirror-link-preload' --> 'Template:Documentation/mirror' -- 'sandbox-link-display' --> 'sandbox' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display'--> 'edit' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'testcases-create-link-display' --> 'create' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display' --> 'edit' -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases' -- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases' -- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.' -- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle local testcasesTitle = env.testcasesTitle local templatePage = templateTitle.prefixedText if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then return nil end -- Make links. local sandboxLinks, testcasesLinks if sandboxTitle.exists then local sandboxPage = sandboxTitle.prefixedText local sandboxDisplay = message('sandbox-link-display') local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) local sandboxEditDisplay = message('sandbox-edit-link-display') local sandboxEditLink = makeWikilink("Special:EditPage/" .. sandboxPage, sandboxEditDisplay) local compareUrl = env.compareUrl local compareLink if compareUrl then local compareDisplay = message('compare-link-display') compareLink = makeUrlLink(compareUrl, compareDisplay) end sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) else local sandboxPreload if subjectSpace == 828 then sandboxPreload = message('module-sandbox-preload') else sandboxPreload = message('template-sandbox-preload') end local sandboxCreateUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = sandboxPreload} local sandboxCreateDisplay = message('sandbox-create-link-display') local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) local mirrorPreload = message('mirror-link-preload') local mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} if subjectSpace == 828 then mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary} end local mirrorDisplay = message('mirror-link-display') local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) end if testcasesTitle.exists then local testcasesPage = testcasesTitle.prefixedText local testcasesDisplay = message('testcases-link-display') local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) local testcasesEditUrl = testcasesTitle:canonicalUrl{action = 'edit'} local testcasesEditDisplay = message('testcases-edit-link-display') local testcasesEditLink = makeWikilink("Special:EditPage/" .. testcasesPage, testcasesEditDisplay) -- for Modules, add testcases run link if exists if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then local testcasesRunLinkDisplay = message('testcases-run-link-display') local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink) else testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) end else local testcasesPreload if subjectSpace == 828 then testcasesPreload = message('module-testcases-preload') else testcasesPreload = message('template-testcases-preload') end local testcasesCreateUrl = testcasesTitle:canonicalUrl{action = 'edit', preload = testcasesPreload} local testcasesCreateDisplay = message('testcases-create-link-display') local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink) end local messageName if subjectSpace == 828 then messageName = 'experiment-blurb-module' else messageName = 'experiment-blurb-template' end return message(messageName, {sandboxLinks, testcasesLinks}) end function p.makeCategoriesBlurb(args, env) --[[ -- Generates the text "Please add categories to the /doc subpage." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'doc-link-display' --> '/doc' -- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.' --]] local docTitle = env.docTitle if not docTitle then return nil end local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display')) return message('add-categories-blurb', {docPathLink}) end function p.makeSubpagesBlurb(args, env) --[[ -- Generates the "Subpages of this template" link. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'template-pagetype' --> 'template' -- 'module-pagetype' --> 'module' -- 'default-pagetype' --> 'page' -- 'subpages-link-display' --> 'Subpages of this $1' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle if not subjectSpace or not templateTitle then return nil end local pagetype if subjectSpace == 10 then pagetype = message('template-pagetype') elseif subjectSpace == 828 then pagetype = message('module-pagetype') else pagetype = message('default-pagetype') end local subpagesLink = makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpages-link-display', {pagetype}) ) return message('subpages-blurb', {subpagesLink}) end ---------------------------------------------------------------------------- -- Tracking categories ---------------------------------------------------------------------------- function p.addTrackingCategories(env) --[[ -- Check if {{documentation}} is transcluded on a /doc or /testcases page. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'display-strange-usage-category' --> true -- 'doc-subpage' --> 'doc' -- 'testcases-subpage' --> 'testcases' -- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage' -- -- /testcases pages in the module namespace are not categorised, as they may have -- {{documentation}} transcluded automatically. --]] local title = env.title local subjectSpace = env.subjectSpace if not title or not subjectSpace then return nil end local subpage = title.subpageText if message('display-strange-usage-category', nil, 'boolean') and ( subpage == message('doc-subpage') or subjectSpace ~= 828 and subpage == message('testcases-subpage') ) then return makeCategoryLink(message('strange-usage-category')) end return '' end return p d6c1bffca24be2d81fa882315ac613f5bb6b227c Module:Effective protection level 828 35 68 2024-01-15T21:44:42Z wikipedia>Pppery 0 Per [[WP:ACPERM]], you need to be autoconfirmed to create pages in mainspace Scribunto text/plain local p = {} -- Returns the permission required to perform a given action on a given title. -- If no title is specified, the title of the page being displayed is used. function p._main(action, pagename) local title if type(pagename) == 'table' and pagename.prefixedText then title = pagename elseif pagename then title = mw.title.new(pagename) else title = mw.title.getCurrentTitle() end pagename = title.prefixedText if action == 'autoreview' then local level = mw.ext.FlaggedRevs.getStabilitySettings(title) level = level and level.autoreview if level == 'review' then return 'reviewer' elseif level ~= '' then return level else return nil -- not '*'. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not '', as that would mean PC-protected but nobody can review end elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then error( 'First parameter must be one of edit, move, create, upload, undelete, autoreview', 2 ) end if title.namespace == 8 then -- MediaWiki namespace if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page return 'interfaceadmin' else -- any non-JS/CSS MediaWiki page return 'sysop' end elseif title.namespace == 2 and title.isSubpage then if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page return 'interfaceadmin' elseif title.contentModel == 'json' then -- user JSON page return 'sysop' end end if action == 'undelete' then return 'sysop' end local level = title.protectionLevels[action] and title.protectionLevels[action][1] if level == 'sysop' or level == 'editprotected' then return 'sysop' elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page return 'sysop' elseif level == 'templateeditor' then return 'templateeditor' elseif action == 'move' then local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move. if blacklistentry and not blacklistentry.params.autoconfirmed then return 'templateeditor' elseif title.namespace == 6 then return 'filemover' elseif level == 'extendedconfirmed' then return 'extendedconfirmed' else return 'autoconfirmed' end end local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename) if blacklistentry then if not blacklistentry.params.autoconfirmed then return 'templateeditor' elseif level == 'extendedconfirmed' then return 'extendedconfirmed' else return 'autoconfirmed' end elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason return 'autoconfirmed' elseif level then return level elseif action == 'upload' then return 'autoconfirmed' elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts if title.namespace == 0 then return 'autoconfirmed' -- Per [[WP:ACPERM]], you need to be autoconfirmed to create pages in mainspace end return 'user' else return '*' end end setmetatable(p, { __index = function(t, k) return function(frame) return t._main(k, frame.args[1]) end end }) return p b6cb1e5589ec6575118f60841644cd65defa7174 Module:High-use 828 48 106 2024-02-07T02:05:53Z wikipedia>Pppery 0 Don't auto-categorize redirects Scribunto text/plain local p = {} -- _fetch looks at the "demo" argument. local _fetch = require('Module:Transclusion_count').fetch local yesno = require('Module:Yesno') function p.num(frame, count) if count == nil then if yesno(frame.args['fetch']) == false then if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end else count = _fetch(frame) end end -- Build output string local return_value = "" if count == nil then if frame.args[1] == "risk" then return "a very large number of" else return "many" end else -- Use 2 significant figures for smaller numbers and 3 for larger ones local sigfig = 2 if count >= 100000 then sigfig = 3 end -- Prepare to round to appropriate number of sigfigs local f = math.floor(math.log10(count)) - sigfig + 1 -- Round and insert "approximately" or "+" when appropriate if (frame.args[2] == "yes") or (mw.ustring.sub(frame.args[1],-1) == "+") then -- Round down return_value = string.format("%s+", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) ) * (10^(f))) ) else -- Round to nearest return_value = string.format("approximately&#x20;%s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) ) end -- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yes if count and count > 250000 and not yesno (frame:getParent().args['no-percent']) then local percent = math.floor( ( (count/frame:callParserFunction('NUMBEROFPAGES', 'R') ) * 100) + 0.5) if percent >= 1 then return_value = string.format("%s&#x20;pages, or roughly %s%% of all", return_value, percent) end end end return return_value end -- Actions if there is a large (greater than or equal to 100,000) transclusion count function p.risk(frame) if frame.args[1] == "risk" then return "risk" else local count = _fetch(frame) if count and count >= 100000 then return "risk" end end return "" end function p.text(frame, count) -- Only show the information about how this template gets updated if someone -- is actually editing the page and maybe trying to update the count. local bot_text = (frame:preprocess("{{REVISIONID}}") == "") and "\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]])." or '' if count == nil then if yesno(frame.args['fetch']) == false then if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end else count = _fetch(frame) end end local title = mw.title.getCurrentTitle() if title.subpageText == "doc" or title.subpageText == "sandbox" then title = title.basePageTitle end local systemMessages = frame.args['system'] if frame.args['system'] == '' then systemMessages = nil end -- This retrieves the project URL automatically to simplify localiation. local templateCount = ('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format( mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'), mw.uri.encode(title.fullText), p.num(frame, count)) local used_on_text = "'''This " .. (mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template") .. ' is used '; if systemMessages then used_on_text = used_on_text .. systemMessages .. ((count and count > 2000) and ("''', and " .. templateCount) or ("'''")) else used_on_text = used_on_text .. templateCount .. "'''" end local sandbox_text = ("%s's [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages, or in your own [[%s]]. "):format( (mw.title.getCurrentTitle().namespace == 828 and "module" or "template"), title.fullText, title.fullText, mw.title.getCurrentTitle().namespace == 828 and "Module:Sandbox|module sandbox" or "Wikipedia:User pages#SUB|user subpage" ) local infoArg = frame.args["info"] ~= "" and frame.args["info"] if (systemMessages or frame.args[1] == "risk" or (count and count >= 100000) ) then local info = systemMessages and '.<br/>Changes to it can cause immediate changes to the Wikipedia user interface.' or '.' if infoArg then info = info .. "<br />" .. infoArg end sandbox_text = info .. '<br /> To avoid major disruption' .. (count and count >= 100000 and ' and server load' or '') .. ', any changes should be tested in the ' .. sandbox_text .. 'The tested changes can be added to this page in a single edit. ' else sandbox_text = (infoArg and ('.<br />' .. infoArg .. ' C') or ' and c') .. 'hanges may be widely noticed. Test changes in the ' .. sandbox_text end local discussion_text = systemMessages and 'Please discuss changes ' or 'Consider discussing changes ' if frame.args["2"] and frame.args["2"] ~= "" and frame.args["2"] ~= "yes" then discussion_text = string.format("%sat [[%s]]", discussion_text, frame.args["2"]) else discussion_text = string.format("%son the [[%s|talk page]]", discussion_text, title.talkPageTitle.fullText ) end return used_on_text .. sandbox_text .. discussion_text .. " before implementing them." .. bot_text end function p.main(frame) local count = nil if yesno(frame.args['fetch']) == false then if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end else count = _fetch(frame) end local image = "[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]" local type_param = "style" local epilogue = '' if frame.args['system'] and frame.args['system'] ~= '' then image = "[[File:Ambox important.svg|40px|alt=Warning|link=]]" type_param = "content" local nocat = frame:getParent().args['nocat'] or frame.args['nocat'] local categorise = (nocat == '' or not yesno(nocat)) if categorise and not mw.title.getCurrentTitle().isRedirect then epilogue = frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}') end elseif (frame.args[1] == "risk" or (count and count >= 100000)) then image = "[[File:Ambox warning orange.svg|40px|alt=Warning|link=]]" type_param = "content" end if frame.args["form"] == "editnotice" then return frame:expandTemplate{ title = 'editnotice', args = { ["image"] = image, ["text"] = p.text(frame, count), ["expiry"] = (frame.args["expiry"] or "") } } .. epilogue else return require('Module:Message box').main('ombox', { type = type_param, image = image, text = p.text(frame, count), expiry = (frame.args["expiry"] or "") }) .. epilogue end end return p e22649bbbdf0185575aade09174113873db5066a Template:Stub documentation 10 52 114 2024-02-14T11:33:40Z wikipedia>Paine Ellsworth 0 remove template-generated high use template from this page wikitext text/x-wiki {{#ifeq:{{FULLPAGENAME}}|Template:Stub documentation||{{#ifeq:{{#invoke:High-use|num|x}}|many||{{High-use}}}}}} This is a '''stub template'''. A brief explanation of these templates follows; for full details please consult [[Wikipedia:Stub]]. === What is a stub? === A stub is an article containing only a few sentences of text which is too short to provide encyclopedic coverage of a subject. === How is a stub identified? === * If possible, try to find the most appropriate stub template for the article. A full list can be found at [[Wikipedia:WikiProject Stub sorting/List of stubs]]. * More than one stub template may be used, if necessary, though no more than four should be used on any article. * Place a stub template ''[[Wikipedia:Manual of Style/Layout#Order of article elements|at the very end]]'' of the article, after the "External links" section, any navigation templates, and the category tags. As usual, templates are added by including their name inside double braces, e.g. <code><nowiki>{{stub}}</nowiki></code>. === Further information === Further information can be found at: * [[Wikipedia:Stub]] * [[Wikipedia:WikiProject Stub sorting]] New stub templates and categories (collectively "stub types") should not be created without prior proposal at [[Wikipedia:WikiProject Stub sorting/Proposals]]. This allows for the proper coordination of all stub types across Wikipedia, and for the checking of any new stub type for possible problems prior to its creation. === See also === * [[Template:Empty section]] – To flag an empty section as a '''stub section''' * [[Template:Expand section]] – To flag sections selectively as incomplete * [[Template:Data missing]] – To flag missing information or other data * [[Wikipedia:Content assessment]]<!-- --><noinclude> {{documentation}} </noinclude> 693be74f03bfbb6824dc219028fd113c04317947 Module:Protection banner/config 828 41 80 2024-03-01T12:45:46Z wikipedia>SilverLocust 0 Fix for [[Template talk:Db-a1]] and similar template-protected non-template redirects being miscategorized into [[Category:Wikipedia fully protected pages]]. Scribunto text/plain -- This module provides configuration data for [[Module:Protection banner]]. return { -------------------------------------------------------------------------------- -- -- BANNER DATA -- -------------------------------------------------------------------------------- --[[ -- Banner data consists of six fields: -- * text - the main protection text that appears at the top of protection -- banners. -- * explanation - the text that appears below the main protection text, used -- to explain the details of the protection. -- * tooltip - the tooltip text you see when you move the mouse over a small -- padlock icon. -- * link - the page that the small padlock icon links to. -- * alt - the alt text for the small padlock icon. This is also used as tooltip -- text for the large protection banners. -- * image - the padlock image used in both protection banners and small padlock -- icons. -- -- The module checks in three separate tables to find a value for each field. -- First it checks the banners table, which has values specific to the reason -- for the page being protected. Then the module checks the defaultBanners -- table, which has values specific to each protection level. Finally, the -- module checks the masterBanner table, which holds data for protection -- templates to use if no data has been found in the previous two tables. -- -- The values in the banner data can take parameters. These are specified -- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name -- enclosed in curly braces). -- -- Available parameters: -- -- ${CURRENTVERSION} - a link to the page history or the move log, with the -- display message "current-version-edit-display" or -- "current-version-move-display". -- -- ${EDITREQUEST} - a link to create an edit request for the current page. -- -- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes -- on the talk page; you may submit a request to ask an administrator to make -- an edit if it is minor or supported by consensus." -- -- ${IMAGELINK} - a link to set the image to, depending on the protection -- action and protection level. -- -- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry -- is set. E.g. "Editing of this page by new or unregistered users is currently -- disabled until dd Month YYYY." -- -- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation -- so that it can be used in run-on sentences. -- -- ${PAGETYPE} - the type of the page, e.g. "article" or "template". -- Defined in the cfg.pagetypes table. -- -- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g. -- "Editing of this page by new or unregistered users is currently disabled" -- -- ${PROTECTIONDATE} - the protection date, if it has been supplied to the -- template. -- -- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or -- "semi-protected". -- -- ${PROTECTIONLOG} - a link to the protection log or the pending changes log, -- depending on the protection action. -- -- ${TALKPAGE} - a link to the talk page. If a section is specified, links -- straight to that talk page section. -- -- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to -- create a blurb like "This template is semi-protected", or "This article is -- move-protected until DD Month YYYY". -- -- ${VANDAL} - links for the specified username (or the root page name) -- using Module:Vandal-m. -- -- Functions -- -- For advanced users, it is possible to use Lua functions instead of strings -- in the banner config tables. Using functions gives flexibility that is not -- possible just by using parameters. Functions take two arguments, the -- protection object and the template arguments, and they must output a string. -- -- For example: -- -- text = function (protectionObj, args) -- if protectionObj.level == 'autoconfirmed' then -- return 'foo' -- else -- return 'bar' -- end -- end -- -- Some protection object properties and methods that may be useful: -- protectionObj.action - the protection action -- protectionObj.level - the protection level -- protectionObj.reason - the protection reason -- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set -- to indefinite, and the protection time in unix time if temporary. -- protectionObj.protectionDate - the protection date in unix time, or nil if -- unspecified. -- protectionObj.bannerConfig - the banner config found by the module. Beware -- of editing the config field used by the function, as it could create an -- infinite loop. -- protectionObj:isProtected - returns a boolean showing whether the page is -- protected. -- protectionObj:isTemporary - returns a boolean showing whether the expiry is -- temporary. -- protectionObj:isIncorrect - returns a boolean showing whether the protection -- template is incorrect. --]] -- The master banner data, used if no values have been found in banners or -- defaultBanners. masterBanner = { text = '${INTROBLURB}', explanation = '${EXPLANATIONBLURB}', tooltip = '${TOOLTIPBLURB}', link = '${IMAGELINK}', alt = 'Page ${PROTECTIONLEVEL}' }, -- The default banner data. This holds banner data for different protection -- levels. -- *required* - this table needs edit, move, autoreview and upload subtables. defaultBanners = { edit = {}, move = {}, autoreview = { default = { alt = 'Page protected with pending changes', tooltip = 'All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users', image = 'Pending-protection-shackle.svg' } }, upload = {} }, -- The banner data. This holds banner data for different protection reasons. -- In fact, the reasons specified in this table control which reasons are -- valid inputs to the first positional parameter. -- -- There is also a non-standard "description" field that can be used for items -- in this table. This is a description of the protection reason for use in the -- module documentation. -- -- *required* - this table needs edit, move, autoreview and upload subtables. banners = { edit = { blp = { description = 'For pages protected to promote compliance with the' .. ' [[Wikipedia:Biographies of living persons' .. '|biographies of living persons]] policy', text = '${INTROFRAGMENT} to promote compliance with' .. ' [[Wikipedia:Biographies of living persons' .. "|Wikipedia's&nbsp;policy on&nbsp;the&nbsp;biographies" .. ' of&nbsp;living&nbsp;people]].', tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on' .. ' biographies of living persons', }, dmca = { description = 'For pages protected by the Wikimedia Foundation' .. ' due to [[Digital Millennium Copyright Act]] takedown requests', explanation = function (protectionObj, args) local ret = 'Pursuant to a rights owner notice under the Digital' .. ' Millennium Copyright Act (DMCA) regarding some content' .. ' in this article, the Wikimedia Foundation acted under' .. ' applicable law and took down and restricted the content' .. ' in question.' if args.notice then ret = ret .. ' A copy of the received notice can be found here: ' .. args.notice .. '.' end ret = ret .. ' For more information, including websites discussing' .. ' how to file a counter-notice, please see' .. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}." .. "'''Do not remove this template from the article until the" .. " restrictions are withdrawn'''." return ret end, image = 'Office-protection-shackle.svg', }, dispute = { description = 'For pages protected due to editing disputes', text = function (protectionObj, args) -- Find the value of "disputes". local display = 'disputes' local disputes if args.section then disputes = string.format( '[[%s:%s#%s|%s]]', mw.site.namespaces[protectionObj.title.namespace].talk.name, protectionObj.title.text, args.section, display ) else disputes = display end -- Make the blurb, depending on the expiry. local msg if type(protectionObj.expiry) == 'number' then msg = '${INTROFRAGMENT} or until editing %s have been resolved.' else msg = '${INTROFRAGMENT} until editing %s have been resolved.' end return string.format(msg, disputes) end, explanation = "This protection is '''not''' an endorsement of the" .. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}', tooltip = '${TOOLTIPFRAGMENT} due to editing disputes', }, ecp = { description = 'For articles in topic areas authorized by' .. ' [[Wikipedia:Arbitration Committee|ArbCom]] or' .. ' meets the criteria for community use', tooltip = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}', alt = 'Extended-protected ${PAGETYPE}', }, mainpage = { description = 'For pages protected for being displayed on the [[Main Page]]', text = 'This file is currently' .. ' [[Wikipedia:This page is protected|protected]] from' .. ' editing because it is currently or will soon be displayed' .. ' on the [[Main Page]].', explanation = 'Images on the Main Page are protected due to their high' .. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.' .. '<br /><span style="font-size:90%;">' .. "'''Administrators:''' Once this image is definitely off the Main Page," .. ' please unprotect this file, or reduce to semi-protection,' .. ' as appropriate.</span>', }, office = { description = 'For pages protected by the Wikimedia Foundation', text = function (protectionObj, args) local ret = 'This ${PAGETYPE} is currently under the' .. ' scrutiny of the' .. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]' .. ' and is protected.' if protectionObj.protectionDate then ret = ret .. ' It has been protected since ${PROTECTIONDATE}.' end return ret end, explanation = "If you can edit this page, please discuss all changes and" .. " additions on the ${TALKPAGE} first. '''Do not remove protection from this" .. " page unless you are authorized by the Wikimedia Foundation to do" .. " so.'''", image = 'Office-protection-shackle.svg', }, reset = { description = 'For pages protected by the Wikimedia Foundation and' .. ' "reset" to a bare-bones version', text = 'This ${PAGETYPE} is currently under the' .. ' scrutiny of the' .. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]' .. ' and is protected.', explanation = function (protectionObj, args) local ret = '' if protectionObj.protectionDate then ret = ret .. 'On ${PROTECTIONDATE} this ${PAGETYPE} was' else ret = ret .. 'This ${PAGETYPE} has been' end ret = ret .. ' reduced to a' .. ' simplified, "bare bones" version so that it may be completely' .. ' rewritten to ensure it meets the policies of' .. ' [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].' .. ' Standard Wikipedia policies will apply to its rewriting—which' .. ' will eventually be open to all editors—and will be strictly' .. ' enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while' .. ' it is being rebuilt.\n\n' .. 'Any insertion of material directly from' .. ' pre-protection revisions of the ${PAGETYPE} will be removed, as' .. ' will any material added to the ${PAGETYPE} that is not properly' .. ' sourced. The associated talk page(s) were also cleared on the' .. " same date.\n\n" .. "If you can edit this page, please discuss all changes and" .. " additions on the ${TALKPAGE} first. '''Do not override" .. " this action, and do not remove protection from this page," .. " unless you are authorized by the Wikimedia Foundation" .. " to do so. No editor may remove this notice.'''" return ret end, image = 'Office-protection-shackle.svg', }, sock = { description = 'For pages protected due to' .. ' [[Wikipedia:Sock puppetry|sock puppetry]]', text = '${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of' .. ' [[Wikipedia:Blocking policy|blocked]] or' .. ' [[Wikipedia:Banning policy|banned users]]' .. ' from editing it.', tooltip = '${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from' .. ' editing it', }, template = { description = 'For [[Wikipedia:High-risk templates|high-risk]]' .. ' templates and Lua modules', text = 'This is a permanently [[Help:Protection|protected]] ${PAGETYPE},' .. ' as it is [[Wikipedia:High-risk templates|high-risk]].', explanation = 'Please discuss any changes on the ${TALKPAGE}; you may' .. ' ${EDITREQUEST} to ask an' .. ' [[Wikipedia:Administrators|administrator]] or' .. ' [[Wikipedia:Template editor|template editor]] to make an edit if' .. ' it is [[Help:Minor edit#When to mark an edit as a minor edit' .. '|uncontroversial]] or supported by' .. ' [[Wikipedia:Consensus|consensus]]. You can also' .. ' [[Wikipedia:Requests for page protection|request]] that the page be' .. ' unprotected.', tooltip = 'This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}' .. ' to prevent vandalism', alt = 'Permanently protected ${PAGETYPE}', }, usertalk = { description = 'For pages protected against disruptive edits by a' .. ' particular user', text = '${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,' .. ' such as abusing the' .. ' &#123;&#123;[[Template:unblock|unblock]]&#125;&#125; template.', explanation = 'If you cannot edit this user talk page and you need to' .. ' make a change or leave a message, you can' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for edits to a protected page' .. '|request an edit]],' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for reduction in protection level' .. '|request unprotection]],' .. ' [[Special:Userlogin|log in]],' .. ' or [[Special:UserLogin/signup|create an account]].', }, vandalism = { description = 'For pages protected against' .. ' [[Wikipedia:Vandalism|vandalism]]', text = '${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].', explanation = function (protectionObj, args) local ret = '' if protectionObj.level == 'sysop' then ret = ret .. "This protection is '''not''' an endorsement of the" .. ' ${CURRENTVERSION}. ' end return ret .. '${EXPLANATIONBLURB}' end, tooltip = '${TOOLTIPFRAGMENT} due to vandalism', } }, move = { dispute = { description = 'For pages protected against page moves due to' .. ' disputes over the page title', explanation = "This protection is '''not''' an endorsement of the" .. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}', image = 'Move-protection-shackle.svg' }, vandalism = { description = 'For pages protected against' .. ' [[Wikipedia:Vandalism#Page-move vandalism' .. ' |page-move vandalism]]' } }, autoreview = {}, upload = {} }, -------------------------------------------------------------------------------- -- -- GENERAL DATA TABLES -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Protection blurbs -------------------------------------------------------------------------------- -- This table produces the protection blurbs available with the -- ${PROTECTIONBLURB} parameter. It is sorted by protection action and -- protection level, and is checked by the module in the following order: -- 1. page's protection action, page's protection level -- 2. page's protection action, default protection level -- 3. "edit" protection action, default protection level -- -- It is possible to use banner parameters inside this table. -- *required* - this table needs edit, move, autoreview and upload subtables. protectionBlurbs = { edit = { default = 'This ${PAGETYPE} is currently [[Help:Protection|' .. 'protected]] from editing', autoconfirmed = 'Editing of this ${PAGETYPE} by [[Wikipedia:User access' .. ' levels#New users|new]] or [[Wikipedia:User access levels#Unregistered' .. ' users|unregistered]] users is currently [[Help:Protection|disabled]]', extendedconfirmed = 'This ${PAGETYPE} is currently under extended confirmed protection', }, move = { default = 'This ${PAGETYPE} is currently [[Help:Protection|protected]]' .. ' from [[Help:Moving a page|page moves]]' }, autoreview = { default = 'All edits made to this ${PAGETYPE} by' .. ' [[Wikipedia:User access levels#New users|new]] or' .. ' [[Wikipedia:User access levels#Unregistered users|unregistered]]' .. ' users are currently' .. ' [[Wikipedia:Pending changes|subject to review]]' }, upload = { default = 'Uploading new versions of this ${PAGETYPE} is currently disabled' } }, -------------------------------------------------------------------------------- -- Explanation blurbs -------------------------------------------------------------------------------- -- This table produces the explanation blurbs available with the -- ${EXPLANATIONBLURB} parameter. It is sorted by protection action, -- protection level, and whether the page is a talk page or not. If the page is -- a talk page it will have a talk key of "talk"; otherwise it will have a talk -- key of "subject". The table is checked in the following order: -- 1. page's protection action, page's protection level, page's talk key -- 2. page's protection action, page's protection level, default talk key -- 3. page's protection action, default protection level, page's talk key -- 4. page's protection action, default protection level, default talk key -- -- It is possible to use banner parameters inside this table. -- *required* - this table needs edit, move, autoreview and upload subtables. explanationBlurbs = { edit = { autoconfirmed = { subject = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details. If you' .. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can' .. ' ${EDITREQUEST}, discuss changes on the ${TALKPAGE},' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for reduction in protection level' .. '|request unprotection]], [[Special:Userlogin|log in]], or' .. ' [[Special:UserLogin/signup|create an account]].', default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details. If you' .. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for reduction in protection level' .. '|request unprotection]], [[Special:Userlogin|log in]], or' .. ' [[Special:UserLogin/signup|create an account]].', }, extendedconfirmed = { default = 'Extended confirmed protection prevents edits from all unregistered editors' .. ' and registered users with fewer than 30 days tenure and 500 edits.' .. ' The [[Wikipedia:Protection policy#extended|policy on community use]]' .. ' specifies that extended confirmed protection can be applied to combat' .. ' disruption, if semi-protection has proven to be ineffective.' .. ' Extended confirmed protection may also be applied to enforce' .. ' [[Wikipedia:Arbitration Committee|arbitration sanctions]].' .. ' Please discuss any changes on the ${TALKPAGE}; you may' .. ' ${EDITREQUEST} to ask for uncontroversial changes supported by' .. ' [[Wikipedia:Consensus|consensus]].' }, default = { subject = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' Please discuss any changes on the ${TALKPAGE}; you' .. ' may ${EDITREQUEST} to ask an' .. ' [[Wikipedia:Administrators|administrator]] to make an edit if it' .. ' is [[Help:Minor edit#When to mark an edit as a minor edit' .. '|uncontroversial]] or supported by [[Wikipedia:Consensus' .. '|consensus]]. You may also [[Wikipedia:Requests for' .. ' page protection#Current requests for reduction in protection level' .. '|request]] that this page be unprotected.', default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' You may [[Wikipedia:Requests for page' .. ' protection#Current requests for edits to a protected page|request an' .. ' edit]] to this page, or [[Wikipedia:Requests for' .. ' page protection#Current requests for reduction in protection level' .. '|ask]] for it to be unprotected.' } }, move = { default = { subject = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' The page may still be edited but cannot be moved' .. ' until unprotected. Please discuss any suggested moves on the' .. ' ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also' .. ' [[Wikipedia:Requests for page protection|request]] that the page be' .. ' unprotected.', default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' The page may still be edited but cannot be moved' .. ' until unprotected. Please discuss any suggested moves at' .. ' [[Wikipedia:Requested moves]]. You can also' .. ' [[Wikipedia:Requests for page protection|request]] that the page be' .. ' unprotected.' } }, autoreview = { default = { default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' Edits to this ${PAGETYPE} by new and unregistered users' .. ' will not be visible to readers until they are accepted by' .. ' a reviewer. To avoid the need for your edits to be' .. ' reviewed, you may' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for reduction in protection level' .. '|request unprotection]], [[Special:Userlogin|log in]], or' .. ' [[Special:UserLogin/signup|create an account]].' }, }, upload = { default = { default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' The page may still be edited but new versions of the file' .. ' cannot be uploaded until it is unprotected. You can' .. ' request that a new version be uploaded by using a' .. ' [[Wikipedia:Edit requests|protected edit request]], or you' .. ' can [[Wikipedia:Requests for page protection|request]]' .. ' that the file be unprotected.' } } }, -------------------------------------------------------------------------------- -- Protection levels -------------------------------------------------------------------------------- -- This table provides the data for the ${PROTECTIONLEVEL} parameter, which -- produces a short label for different protection levels. It is sorted by -- protection action and protection level, and is checked in the following -- order: -- 1. page's protection action, page's protection level -- 2. page's protection action, default protection level -- 3. "edit" protection action, default protection level -- -- It is possible to use banner parameters inside this table. -- *required* - this table needs edit, move, autoreview and upload subtables. protectionLevels = { edit = { default = 'protected', templateeditor = 'template-protected', extendedconfirmed = 'extended-protected', autoconfirmed = 'semi-protected', }, move = { default = 'move-protected' }, autoreview = { }, upload = { default = 'upload-protected' } }, -------------------------------------------------------------------------------- -- Images -------------------------------------------------------------------------------- -- This table lists different padlock images for each protection action and -- protection level. It is used if an image is not specified in any of the -- banner data tables, and if the page does not satisfy the conditions for using -- the ['image-filename-indef'] image. It is checked in the following order: -- 1. page's protection action, page's protection level -- 2. page's protection action, default protection level images = { edit = { default = 'Full-protection-shackle.svg', templateeditor = 'Template-protection-shackle.svg', extendedconfirmed = 'Extended-protection-shackle.svg', autoconfirmed = 'Semi-protection-shackle.svg' }, move = { default = 'Move-protection-shackle.svg', }, autoreview = { default = 'Pending-protection-shackle.svg' }, upload = { default = 'Upload-protection-shackle.svg' } }, -- Pages with a reason specified in this table will show the special "indef" -- padlock, defined in the 'image-filename-indef' message, if no expiry is set. indefImageReasons = { template = true }, -------------------------------------------------------------------------------- -- Image links -------------------------------------------------------------------------------- -- This table provides the data for the ${IMAGELINK} parameter, which gets -- the image link for small padlock icons based on the page's protection action -- and protection level. It is checked in the following order: -- 1. page's protection action, page's protection level -- 2. page's protection action, default protection level -- 3. "edit" protection action, default protection level -- -- It is possible to use banner parameters inside this table. -- *required* - this table needs edit, move, autoreview and upload subtables. imageLinks = { edit = { default = 'Wikipedia:Protection policy#full', templateeditor = 'Wikipedia:Protection policy#template', extendedconfirmed = 'Wikipedia:Protection policy#extended', autoconfirmed = 'Wikipedia:Protection policy#semi' }, move = { default = 'Wikipedia:Protection policy#move' }, autoreview = { default = 'Wikipedia:Protection policy#pending' }, upload = { default = 'Wikipedia:Protection policy#upload' } }, -------------------------------------------------------------------------------- -- Padlock indicator names -------------------------------------------------------------------------------- -- This table provides the "name" attribute for the <indicator> extension tag -- with which small padlock icons are generated. All indicator tags on a page -- are displayed in alphabetical order based on this attribute, and with -- indicator tags with duplicate names, the last tag on the page wins. -- The attribute is chosen based on the protection action; table keys must be a -- protection action name or the string "default". padlockIndicatorNames = { autoreview = 'pp-autoreview', default = 'pp-default' }, -------------------------------------------------------------------------------- -- Protection categories -------------------------------------------------------------------------------- --[[ -- The protection categories are stored in the protectionCategories table. -- Keys to this table are made up of the following strings: -- -- 1. the expiry date -- 2. the namespace -- 3. the protection reason (e.g. "dispute" or "vandalism") -- 4. the protection level (e.g. "sysop" or "autoconfirmed") -- 5. the action (e.g. "edit" or "move") -- -- When the module looks up a category in the table, first it will will check to -- see a key exists that corresponds to all five parameters. For example, a -- user page semi-protected from vandalism for two weeks would have the key -- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module -- changes the first part of the key to "all" and checks the table again. It -- keeps checking increasingly generic key combinations until it finds the -- field, or until it reaches the key "all-all-all-all-all". -- -- The module uses a binary matrix to determine the order in which to search. -- This is best demonstrated by a table. In this table, the "0" values -- represent "all", and the "1" values represent the original data (e.g. -- "indef" or "file" or "vandalism"). -- -- expiry namespace reason level action -- order -- 1 1 1 1 1 1 -- 2 0 1 1 1 1 -- 3 1 0 1 1 1 -- 4 0 0 1 1 1 -- 5 1 1 0 1 1 -- 6 0 1 0 1 1 -- 7 1 0 0 1 1 -- 8 0 0 0 1 1 -- 9 1 1 1 0 1 -- 10 0 1 1 0 1 -- 11 1 0 1 0 1 -- 12 0 0 1 0 1 -- 13 1 1 0 0 1 -- 14 0 1 0 0 1 -- 15 1 0 0 0 1 -- 16 0 0 0 0 1 -- 17 1 1 1 1 0 -- 18 0 1 1 1 0 -- 19 1 0 1 1 0 -- 20 0 0 1 1 0 -- 21 1 1 0 1 0 -- 22 0 1 0 1 0 -- 23 1 0 0 1 0 -- 24 0 0 0 1 0 -- 25 1 1 1 0 0 -- 26 0 1 1 0 0 -- 27 1 0 1 0 0 -- 28 0 0 1 0 0 -- 29 1 1 0 0 0 -- 30 0 1 0 0 0 -- 31 1 0 0 0 0 -- 32 0 0 0 0 0 -- -- In this scheme the action has the highest priority, as it is the last -- to change, and the expiry has the least priority, as it changes the most. -- The priorities of the expiry, the protection level and the action are -- fixed, but the priorities of the reason and the namespace can be swapped -- through the use of the cfg.bannerDataNamespaceHasPriority table. --]] -- If the reason specified to the template is listed in this table, -- namespace data will take priority over reason data in the protectionCategories -- table. reasonsWithNamespacePriority = { vandalism = true, }, -- The string to use as a namespace key for the protectionCategories table for each -- namespace number. categoryNamespaceKeys = { [ 2] = 'user', [ 3] = 'user', [ 4] = 'project', [ 6] = 'file', [ 8] = 'mediawiki', [ 10] = 'template', [ 12] = 'project', [ 14] = 'category', [100] = 'portal', [828] = 'module', }, protectionCategories = { ['all|all|all|all|all'] = 'Wikipedia fully protected pages', ['all|all|office|all|all'] = 'Wikipedia Office-protected pages', ['all|all|reset|all|all'] = 'Wikipedia Office-protected pages', ['all|all|dmca|all|all'] = 'Wikipedia Office-protected pages', ['all|all|mainpage|all|all'] = 'Wikipedia fully protected main page files', ['all|all|all|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages', ['all|all|ecp|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages', ['all|template|all|all|edit'] = 'Wikipedia fully protected templates', ['all|all|all|autoconfirmed|edit'] = 'Wikipedia semi-protected pages', ['indef|all|all|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected pages', ['all|all|blp|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected biographies of living people', ['temp|all|blp|autoconfirmed|edit'] = 'Wikipedia temporarily semi-protected biographies of living people', ['all|all|dispute|autoconfirmed|edit'] = 'Wikipedia pages semi-protected due to dispute', ['all|all|sock|autoconfirmed|edit'] = 'Wikipedia pages semi-protected from banned users', ['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism', ['all|category|all|autoconfirmed|edit'] = 'Wikipedia semi-protected categories', ['all|file|all|autoconfirmed|edit'] = 'Wikipedia semi-protected files', ['all|portal|all|autoconfirmed|edit'] = 'Wikipedia semi-protected portals', ['all|project|all|autoconfirmed|edit'] = 'Wikipedia semi-protected project pages', ['all|talk|all|autoconfirmed|edit'] = 'Wikipedia semi-protected talk pages', ['all|template|all|autoconfirmed|edit'] = 'Wikipedia semi-protected templates', ['all|user|all|autoconfirmed|edit'] = 'Wikipedia semi-protected user and user talk pages', ['all|all|all|templateeditor|move'] = 'Wikipedia template-protected pages other than templates and modules', ['all|all|all|templateeditor|edit'] = 'Wikipedia template-protected pages other than templates and modules', ['all|template|all|templateeditor|edit'] = 'Wikipedia template-protected templates', ['all|template|all|templateeditor|move'] = 'Wikipedia template-protected templates', -- move-protected templates ['all|all|blp|sysop|edit'] = 'Wikipedia indefinitely protected biographies of living people', ['temp|all|blp|sysop|edit'] = 'Wikipedia temporarily protected biographies of living people', ['all|all|dispute|sysop|edit'] = 'Wikipedia pages protected due to dispute', ['all|all|sock|sysop|edit'] = 'Wikipedia pages protected from banned users', ['all|all|vandalism|sysop|edit'] = 'Wikipedia pages protected against vandalism', ['all|category|all|sysop|edit'] = 'Wikipedia fully protected categories', ['all|file|all|sysop|edit'] = 'Wikipedia fully protected files', ['all|project|all|sysop|edit'] = 'Wikipedia fully protected project pages', ['all|talk|all|sysop|edit'] = 'Wikipedia fully protected talk pages', ['all|template|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected templates', ['all|template|all|sysop|edit'] = 'Wikipedia fully protected templates', ['all|user|all|sysop|edit'] = 'Wikipedia fully protected user and user talk pages', ['all|module|all|all|edit'] = 'Wikipedia fully protected modules', ['all|module|all|templateeditor|edit'] = 'Wikipedia template-protected modules', ['all|module|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected modules', ['all|module|all|autoconfirmed|edit'] = 'Wikipedia semi-protected modules', ['all|all|all|sysop|move'] = 'Wikipedia move-protected pages', ['indef|all|all|sysop|move'] = 'Wikipedia indefinitely move-protected pages', ['all|all|dispute|sysop|move'] = 'Wikipedia pages move-protected due to dispute', ['all|all|vandalism|sysop|move'] = 'Wikipedia pages move-protected due to vandalism', ['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals', ['all|project|all|sysop|move'] = 'Wikipedia move-protected project pages', ['all|talk|all|sysop|move'] = 'Wikipedia move-protected talk pages', ['all|template|all|sysop|move'] = 'Wikipedia move-protected templates', ['all|user|all|sysop|move'] = 'Wikipedia move-protected user and user talk pages', ['all|all|all|autoconfirmed|autoreview'] = 'Wikipedia pending changes protected pages', ['all|file|all|all|upload'] = 'Wikipedia upload-protected files', }, -------------------------------------------------------------------------------- -- Expiry category config -------------------------------------------------------------------------------- -- This table configures the expiry category behaviour for each protection -- action. -- * If set to true, setting that action will always categorise the page if -- an expiry parameter is not set. -- * If set to false, setting that action will never categorise the page. -- * If set to nil, the module will categorise the page if: -- 1) an expiry parameter is not set, and -- 2) a reason is provided, and -- 3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck -- table. expiryCheckActions = { edit = nil, move = false, autoreview = true, upload = false }, reasonsWithoutExpiryCheck = { blp = true, template = true, }, -------------------------------------------------------------------------------- -- Pagetypes -------------------------------------------------------------------------------- -- This table produces the page types available with the ${PAGETYPE} parameter. -- Keys are namespace numbers, or the string "default" for the default value. pagetypes = { [0] = 'article', [6] = 'file', [10] = 'template', [14] = 'category', [828] = 'module', default = 'page' }, -------------------------------------------------------------------------------- -- Strings marking indefinite protection -------------------------------------------------------------------------------- -- This table contains values passed to the expiry parameter that mean the page -- is protected indefinitely. indefStrings = { ['indef'] = true, ['indefinite'] = true, ['indefinitely'] = true, ['infinite'] = true, }, -------------------------------------------------------------------------------- -- Group hierarchy -------------------------------------------------------------------------------- -- This table maps each group to all groups that have a superset of the original -- group's page editing permissions. hierarchy = { sysop = {}, reviewer = {'sysop'}, filemover = {'sysop'}, templateeditor = {'sysop'}, extendedconfirmed = {'sysop'}, autoconfirmed = {'reviewer', 'filemover', 'templateeditor', 'extendedconfirmed'}, user = {'autoconfirmed'}, ['*'] = {'user'} }, -------------------------------------------------------------------------------- -- Wrapper templates and their default arguments -------------------------------------------------------------------------------- -- This table contains wrapper templates used with the module, and their -- default arguments. Templates specified in this table should contain the -- following invocation, and no other template content: -- -- {{#invoke:Protection banner|main}} -- -- If other content is desired, it can be added between -- <noinclude>...</noinclude> tags. -- -- When a user calls one of these wrapper templates, they will use the -- default arguments automatically. However, users can override any of the -- arguments. wrappers = { ['Template:Pp'] = {}, ['Template:Pp-extended'] = {'ecp'}, ['Template:Pp-blp'] = {'blp'}, -- we don't need Template:Pp-create ['Template:Pp-dispute'] = {'dispute'}, ['Template:Pp-main-page'] = {'mainpage'}, ['Template:Pp-move'] = {action = 'move', catonly = 'yes'}, ['Template:Pp-move-dispute'] = {'dispute', action = 'move', catonly = 'yes'}, -- we don't need Template:Pp-move-indef ['Template:Pp-move-vandalism'] = {'vandalism', action = 'move', catonly = 'yes'}, ['Template:Pp-office'] = {'office'}, ['Template:Pp-office-dmca'] = {'dmca'}, ['Template:Pp-pc'] = {action = 'autoreview', small = true}, ['Template:Pp-pc1'] = {action = 'autoreview', small = true}, ['Template:Pp-reset'] = {'reset'}, ['Template:Pp-semi-indef'] = {small = true}, ['Template:Pp-sock'] = {'sock'}, ['Template:Pp-template'] = {'template', small = true}, ['Template:Pp-upload'] = {action = 'upload'}, ['Template:Pp-usertalk'] = {'usertalk'}, ['Template:Pp-vandalism'] = {'vandalism'}, }, -------------------------------------------------------------------------------- -- -- MESSAGES -- -------------------------------------------------------------------------------- msg = { -------------------------------------------------------------------------------- -- Intro blurb and intro fragment -------------------------------------------------------------------------------- -- These messages specify what is produced by the ${INTROBLURB} and -- ${INTROFRAGMENT} parameters. If the protection is temporary they use the -- intro-blurb-expiry or intro-fragment-expiry, and if not they use -- intro-blurb-noexpiry or intro-fragment-noexpiry. -- It is possible to use banner parameters in these messages. ['intro-blurb-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY}.', ['intro-blurb-noexpiry'] = '${PROTECTIONBLURB}.', ['intro-fragment-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY},', ['intro-fragment-noexpiry'] = '${PROTECTIONBLURB}', -------------------------------------------------------------------------------- -- Tooltip blurb -------------------------------------------------------------------------------- -- These messages specify what is produced by the ${TOOLTIPBLURB} parameter. -- If the protection is temporary the tooltip-blurb-expiry message is used, and -- if not the tooltip-blurb-noexpiry message is used. -- It is possible to use banner parameters in these messages. ['tooltip-blurb-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.', ['tooltip-blurb-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}.', ['tooltip-fragment-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},', ['tooltip-fragment-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}', -------------------------------------------------------------------------------- -- Special explanation blurb -------------------------------------------------------------------------------- -- An explanation blurb for pages that cannot be unprotected, e.g. for pages -- in the MediaWiki namespace. -- It is possible to use banner parameters in this message. ['explanation-blurb-nounprotect'] = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' Please discuss any changes on the ${TALKPAGE}; you' .. ' may ${EDITREQUEST} to ask an' .. ' [[Wikipedia:Administrators|administrator]] to make an edit if it' .. ' is [[Help:Minor edit#When to mark an edit as a minor edit' .. '|uncontroversial]] or supported by [[Wikipedia:Consensus' .. '|consensus]].', -------------------------------------------------------------------------------- -- Protection log display values -------------------------------------------------------------------------------- -- These messages determine the display values for the protection log link -- or the pending changes log link produced by the ${PROTECTIONLOG} parameter. -- It is possible to use banner parameters in these messages. ['protection-log-display'] = 'protection log', ['pc-log-display'] = 'pending changes log', -------------------------------------------------------------------------------- -- Current version display values -------------------------------------------------------------------------------- -- These messages determine the display values for the page history link -- or the move log link produced by the ${CURRENTVERSION} parameter. -- It is possible to use banner parameters in these messages. ['current-version-move-display'] = 'current title', ['current-version-edit-display'] = 'current version', -------------------------------------------------------------------------------- -- Talk page -------------------------------------------------------------------------------- -- This message determines the display value of the talk page link produced -- with the ${TALKPAGE} parameter. -- It is possible to use banner parameters in this message. ['talk-page-link-display'] = 'talk page', -------------------------------------------------------------------------------- -- Edit requests -------------------------------------------------------------------------------- -- This message determines the display value of the edit request link produced -- with the ${EDITREQUEST} parameter. -- It is possible to use banner parameters in this message. ['edit-request-display'] = 'submit an edit request', -------------------------------------------------------------------------------- -- Expiry date format -------------------------------------------------------------------------------- -- This is the format for the blurb expiry date. It should be valid input for -- the first parameter of the #time parser function. ['expiry-date-format'] = 'F j, Y "at" H:i e', -------------------------------------------------------------------------------- -- Tracking categories -------------------------------------------------------------------------------- -- These messages determine which tracking categories the module outputs. ['tracking-category-incorrect'] = 'Wikipedia pages with incorrect protection templates', ['tracking-category-template'] = 'Wikipedia template-protected pages other than templates and modules', -------------------------------------------------------------------------------- -- Images -------------------------------------------------------------------------------- -- These are images that are not defined by their protection action and protection level. ['image-filename-indef'] = 'Full-protection-shackle.svg', ['image-filename-default'] = 'Transparent.gif', -------------------------------------------------------------------------------- -- End messages -------------------------------------------------------------------------------- } -------------------------------------------------------------------------------- -- End configuration -------------------------------------------------------------------------------- } 65de905227752d0a0dae145e9ad8dbe1d0087016 Module:Documentation/styles.css 828 29 96 2024-03-20T03:28:32Z wikipedia>Jdlrobson 0 Classes have been updated. More information on [[mw:Recommendations_for_night_mode_compatibility_on_Wikimedia_wikis]] sanitized-css text/css /* {{pp|small=yes}} */ .documentation, .documentation-metadata { border: 1px solid #a2a9b1; background-color: #ecfcf4; clear: both; } .documentation { margin: 1em 0 0 0; padding: 1em; } .documentation-metadata { margin: 0.2em 0; /* same margin left-right as .documentation */ font-style: italic; padding: 0.4em 1em; /* same padding left-right as .documentation */ } .documentation-startbox { padding-bottom: 3px; border-bottom: 1px solid #aaa; margin-bottom: 1ex; } .documentation-heading { font-weight: bold; font-size: 125%; } .documentation-clear { /* Don't want things to stick out where they shouldn't. */ clear: both; } .documentation-toolbar { font-style: normal; font-size: 85%; } html.skin-theme-clientpref-night .documentation, html.skin-theme-clientpref-night .documentation-metadata { background-color: inherit; } @media (prefers-color-scheme: dark) { html.skin-theme-clientpref-os .documentation, html.skin-theme-clientpref-os .documentation-metadata { background-color: inherit; } } a086e12b14e61c1254b77cddf71625c15359e806 Template:Module rating 10 63 142 2024-03-26T07:30:47Z wikipedia>Gonnym 0 consolidate category code and disable categories for user sandboxes wikitext text/x-wiki <includeonly>{{#ifeq:{{SUBPAGENAME}}|doc|<!--do not show protection level of the module on the doc page, use the second and optionally third parameter if the doc page is also protected -->{{#if:{{{2|}}}|{{Pp|{{{2}}}|action={{{3|}}}}}}}|{{Module other|{{ombox | type = notice | image = {{#switch: {{{1|}}} | pre-alpha | prealpha | pa = [[File:Ambox warning blue construction.svg|40x40px|link=|alt=Pre-alpha]] | alpha | a = [[File:Greek lc alpha icon.svg|26x26px|link=|alt=Alpha]] | beta | b = [[File:Greek lc beta icon.svg|40x40px|link=|alt=Beta]] | release | r | general | g = [[File:Green check.svg|40x40px|link=|alt=Ready for use]] | protected | protect | p = [[File:{{#switch:{{#invoke:Effective protection level|edit|{{#switch:{{SUBPAGENAME}}|doc|sandbox={{FULLBASEPAGENAME}}|{{FULLPAGENAME}}}}}}|autoconfirmed=Semi|extendedconfirmed=Extended|accountcreator|templateeditor=Template|#default=Full}}-protection-shackle.svg|40x40px|link=|alt=Protected]] | semiprotected | semiprotect | semi =[[File:Semi-protection-shackle.svg|40x40px|link=|alt=Semi-protected]] }} | style = | textstyle = | text = {{#switch: {{{1|}}} | pre-alpha | prealpha | pa = This module is rated as [[:Category:Modules in pre-alpha development|pre-alpha]]. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. | alpha | a = This module is rated as [[:Category:Modules in alpha|alpha]]. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. | beta | b = This module is rated as [[:Category:Modules in beta|beta]], and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. | release | r | general | g = This module is rated as [[:Category:Modules for general use|ready for general use]]. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by [[Wikipedia:Template sandbox and test cases|sandbox testing]] rather than repeated trial-and-error editing. | protected | protect | p = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[Wikipedia:Protection policy|protected]] from editing. | semiprotected | semiprotect | semi = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[WP:SEMI|semi-protected]] from editing. | #default = {{error|Module rating is invalid or not specified.}} }} }}<!-- -->{{#ifeq: {{ROOTPAGENAME}} | Sandbox | <!-- No category for user sandboxes --> | {{#switch: {{SUBPAGENAME}} | doc | sandbox =<!-- No category for /doc or /sandbox subpages --> | {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | {{#switch: {{{1|}}} | pre-alpha | prealpha | pa = [[Category:Modules in pre-alpha development|{{PAGENAME}}]] | alpha | a = [[Category:Modules in alpha|{{PAGENAME}}]] | beta | b = [[Category:Modules in beta|{{PAGENAME}}]] | release | r | general | g = [[Category:Modules for general use|{{PAGENAME}}]] | protected | protect | p = [[Category:Modules subject to page protection|{{PAGENAME}}]] | semiprotected | semiprotect | semi = [[Category:Modules subject to page protection|{{PAGENAME}}]] }} }} }} }}<!-- -->|{{error|Error: {{tl|Module rating}} must be placed in the Module namespace.}} [[Category:Pages with templates in the wrong namespace]]|demospace={{{demospace|<noinclude>module</noinclude>}}}}}}}<!-- --></includeonly><noinclude> {{module rating|release|nocat=true|demospace=module}} {{documentation}} <!-- Categories go on the /doc subpage, and interwikis go in Wikidata. --> </noinclude> 75c928c417eb4da2a338898531fd8d501e05adbb Module:Transclusion count/data/M 828 64 144 2024-03-31T05:13:57Z wikipedia>Ahechtbot 0 [[Wikipedia:BOT|Bot]]: Updated page. Scribunto text/plain return { ["M"] = 2100, ["MAD"] = 2100, ["MAR"] = 2900, ["MAS"] = 2600, ["MDG"] = 2400, ["MEX"] = 6300, ["MILHIST"] = 5100, ["MINUTE"] = 2300, ["MKD"] = 2400, ["MLB_Farm_System"] = 2100, ["MLB_Year"] = 15000, ["MLB_standings"] = 3800, ["MLBplayer"] = 4000, ["MMA_record_start"] = 3700, ["MMArecordbox"] = 3700, ["MMSI_Number"] = 3200, ["MONTH"] = 13000, ["MONTHNAME"] = 859000, ["MONTHNUMBER"] = 873000, ["MS"] = 5400, ["MV"] = 9200, ["MYS"] = 3800, ["MacTutor"] = 2000, ["Main"] = 351000, ["Main_article"] = 31000, ["Main_other"] = 9780000, ["Main_page_image"] = 27000, ["Main_page_image/DYK"] = 11000, ["Main_page_image/ITN/styles.css"] = 2900, ["Main_page_image/TFA"] = 5000, ["Maintenance_category"] = 39000, ["Malay_name"] = 2500, ["Map_requested"] = 6400, ["Map_requested/Category_helper"] = 6300, ["Maplink"] = 37000, ["Maplink-road"] = 6200, ["Marriage"] = 78000, ["Marriage/doc"] = 78000, ["Marriage/styles.css"] = 78000, ["Math"] = 10000, ["MathGenealogy"] = 7200, ["MathWorld"] = 2400, ["Mathgenealogy"] = 2200, ["Max"] = 239000, ["Maybe_free_media"] = 12000, ["Mbox"] = 3190000, ["Mdash"] = 9200, ["MeSH_name"] = 6000, ["Medal"] = 118000, ["MedalBottom"] = 16000, ["MedalBronze"] = 56000, ["MedalComp"] = 2300, ["MedalCompetition"] = 91000, ["MedalCount"] = 3400, ["MedalCountry"] = 81000, ["MedalGold"] = 55000, ["MedalOlympic"] = 4000, ["MedalOlympics"] = 6100, ["MedalSilver"] = 54000, ["MedalSport"] = 80000, ["MedalTableTop"] = 17000, ["MedalTop"] = 3800, ["MedalWorldChampionships"] = 2000, ["MedalistTable"] = 15000, ["Medals_table"] = 15000, ["Media"] = 2600, ["Medical_resources"] = 6900, ["Merge_done"] = 3800, ["Merge_partner"] = 2100, ["Merged-from"] = 17000, ["Merged-to"] = 19000, ["Merged_to"] = 2200, ["MeshName"] = 5900, ["Metacritic_film"] = 4000, ["Metadata_Population_DE-BY"] = 2100, ["Metadata_Population_DE-RP"] = 2300, ["Mhof"] = 7500, ["Mid-Class"] = 15000, ["Mid-importance"] = 15000, ["Middot"] = 6200, ["Midsize"] = 2300, ["MilHist"] = 2700, ["Military_navigation"] = 65000, ["Min"] = 29000, ["Minor_planet"] = 5200, ["Minor_planet_link"] = 2600, ["Minor_planet_list_link"] = 4200, ["Minor_planets_navigator"] = 3200, ["MirrorH"] = 6100, ["Missing_information"] = 3800, ["Mlby"] = 15000, ["Mobile_IP"] = 8500, ["MobyGames"] = 9000, ["Moby_game"] = 7100, ["Mod"] = 7600, ["Module_other"] = 3600, ["Mojo_title"] = 7800, ["Molecular_formula_index"] = 2300, ["Monday"] = 2700, ["Mono"] = 30000, ["Mono/styles.css"] = 31000, ["MonthCategoryNav"] = 36000, ["MonthlyArchive"] = 3700, ["MonthlyLinks"] = 3800, ["Monthly_archive_list"] = 3800, ["Monthly_clean-up_category"] = 16000, ["Monthly_clean-up_category/core"] = 16000, ["Monthly_clean-up_category/monthname"] = 17000, ["Monthly_clean-up_category/monthno"] = 17000, ["Monthly_clean-up_category/name_part"] = 17000, ["Monthly_clean-up_category/outer_core"] = 16000, ["Monthly_clean-up_category/to_add"] = 2900, ["Monthly_clean_up_category"] = 6900, ["Monthyear"] = 64000, ["Monthyear-1"] = 62000, ["MoreInfo"] = 2100, ["More_citations_needed"] = 380000, ["More_citations_needed_section"] = 16000, ["More_footnotes"] = 33000, ["More_footnotes_needed"] = 54000, ["More_plot"] = 3200, ["More_references"] = 3200, ["Moresources"] = 6000, ["Motorcycle_Hall_of_Fame"] = 7500, ["Motorsport_season"] = 5000, ["Motorsport_season/styles.css"] = 5000, ["Moved_discussion_from"] = 3000, ["Moved_discussion_to"] = 2700, ["Mp"] = 5100, ["Mpl"] = 2600, ["MultiReplace"] = 216000, ["Multiple_image"] = 54000, ["Multiple_image/styles.css"] = 54000, ["Multiple_issues"] = 123000, ["Multiple_issues/styles.css"] = 123000, ["Music"] = 7700, ["MusicBrainz_artist"] = 2300, ["MusicBrainz_meta"] = 5400, ["MusicBrainz_release_group"] = 2300, ["Music_ratings"] = 97000, ["Mvar"] = 8100, ["Mw_lang"] = 83000, ["My"] = 2500, ["My_sandbox"] = 3900, ["Myprefs"] = 11000, ["Module:MLB_standings"] = 3800, ["Module:MLB_standings/data"] = 3800, ["Module:Main_page_image"] = 16000, ["Module:Mapframe"] = 455000, ["Module:Math"] = 1590000, ["Module:Medals_table"] = 15000, ["Module:Message_box"] = 18600000, ["Module:Message_box/ambox.css"] = 3230000, ["Module:Message_box/cmbox.css"] = 433000, ["Module:Message_box/configuration"] = 9910000, ["Module:Message_box/fmbox.css"] = 20000, ["Module:Message_box/imbox.css"] = 933000, ["Module:Message_box/ombox.css"] = 1660000, ["Module:Message_box/tmbox.css"] = 12700000, ["Module:Military_navigation"] = 85000, ["Module:Minor_planet_list_link"] = 4200, ["Module:MultiReplace"] = 1290000, ["Module:Multiple_image"] = 54000, ["Module:Music_ratings"] = 97000, ["Module:Mw_lang"] = 83000, } d97f689b81758a648cecd4297ecc6a711751a277 Module:Transclusion count/data/S 828 50 110 2024-03-31T05:14:57Z wikipedia>Ahechtbot 0 [[Wikipedia:BOT|Bot]]: Updated page. Scribunto text/plain return { ["S"] = 3700, ["S-aca"] = 6500, ["S-ach"] = 16000, ["S-aft"] = 220000, ["S-aft/check"] = 220000, ["S-aft/filter"] = 220000, ["S-bef"] = 225000, ["S-bef/check"] = 225000, ["S-bef/filter"] = 225000, ["S-break"] = 5200, ["S-civ"] = 2700, ["S-dip"] = 5500, ["S-end"] = 249000, ["S-gov"] = 8000, ["S-hon"] = 3900, ["S-hou"] = 9600, ["S-inc"] = 13000, ["S-legal"] = 9500, ["S-mil"] = 12000, ["S-new"] = 16000, ["S-non"] = 10000, ["S-npo"] = 4100, ["S-off"] = 41000, ["S-par"] = 51000, ["S-par/en"] = 3300, ["S-par/gb"] = 3300, ["S-par/uk"] = 12000, ["S-par/us-hs"] = 11000, ["S-par/us-sen"] = 2000, ["S-ppo"] = 13000, ["S-prec"] = 3200, ["S-rail"] = 6400, ["S-rail-start"] = 6300, ["S-rail/lines"] = 6400, ["S-reg"] = 21000, ["S-rel"] = 18000, ["S-roy"] = 2800, ["S-s"] = 2800, ["S-sports"] = 11000, ["S-start"] = 242000, ["S-ttl"] = 232000, ["S-ttl/check"] = 232000, ["S-vac"] = 6600, ["SCO"] = 3700, ["SDcat"] = 5730000, ["SECOND"] = 2300, ["SGP"] = 2700, ["SIA"] = 2600, ["SIPA"] = 2800, ["SLO"] = 4300, ["SMS"] = 7400, ["SMU"] = 2200, ["SPI_archive_notice"] = 73000, ["SPIarchive_notice"] = 73000, ["SPIcat"] = 3800, ["SPIclose"] = 3300, ["SPIpriorcases"] = 67000, ["SR/Olympics_profile"] = 3000, ["SRB"] = 3700, ["SS"] = 20000, ["SSPa"] = 2600, ["STN"] = 13000, ["SUBJECTSPACE_formatted"] = 44000, ["SUI"] = 8600, ["SVG"] = 3100, ["SVG-Logo"] = 21000, ["SVG-Res"] = 19000, ["SVG-logo"] = 7900, ["SVK"] = 6000, ["SVN"] = 5200, ["SWE"] = 12000, ["Sandbox_other"] = 247000, ["Saturday"] = 2700, ["Saved_book"] = 52000, ["Sc"] = 2800, ["Scholia"] = 3000, ["School_block"] = 13000, ["School_disambiguation"] = 3300, ["Schoolblock"] = 6800, ["Schooldis"] = 2600, ["Schoolip"] = 11000, ["Scientist_icon"] = 15000, ["Scientist_icon2"] = 15000, ["Sclass"] = 31000, ["Sclass2"] = 10000, ["Screen_reader-only"] = 44000, ["Screen_reader-only/styles.css"] = 45000, ["Script"] = 6200, ["Script/Arabic"] = 2900, ["Script/Hebrew"] = 4800, ["Script/Nastaliq"] = 14000, ["Script/doc/id-unk"] = 3000, ["Script/doc/id-unk/core"] = 3000, ["Script/doc/id-unk/is-iso-alpha4"] = 2900, ["Script/doc/id-unk/name-to-alpha4"] = 3000, ["Script/styles.css"] = 3100, ["Script/styles_arabic.css"] = 2900, ["Script/styles_hebrew.css"] = 4800, ["Sdash"] = 3300, ["Search_box"] = 55000, ["Search_link"] = 16000, ["Section_link"] = 70000, ["Section_sizes"] = 2700, ["See"] = 9900, ["See_also"] = 190000, ["Seealso"] = 6800, ["Select_skin"] = 4400, ["Selected_article"] = 2500, ["Selected_picture"] = 2500, ["Self"] = 46000, ["Self-published_inline"] = 4100, ["Self-published_source"] = 6500, ["Self-reference"] = 2400, ["Self-reference_tool"] = 5700, ["Sent_off"] = 14000, ["Sentoff"] = 4500, ["Separated_entries"] = 196000, ["Sequence"] = 3500, ["Series_overview"] = 8200, ["Serif"] = 3000, ["Set_category"] = 36000, ["Set_index_article"] = 6000, ["Sets_taxobox_colour"] = 68000, ["Sfn"] = 163000, ["SfnRef"] = 138000, ["Sfnm"] = 4000, ["Sfnp"] = 18000, ["Sfnref"] = 12000, ["Sfrac"] = 4400, ["Sfrac/styles.css"] = 4400, ["SharedIPEDU"] = 3300, ["Shared_IP"] = 10000, ["Shared_IP_advice"] = 15000, ["Shared_IP_corp"] = 4300, ["Shared_IP_edu"] = 183000, ["Shared_IP_gov"] = 2400, ["Sharedip"] = 3000, ["Sharedipedu"] = 3700, ["Sherdog"] = 2600, ["Ship"] = 86000, ["Ship/maintenancecategory"] = 86000, ["Ship_index"] = 7000, ["Shipboxflag"] = 20000, ["Shipboxflag/core"] = 20000, ["Shipwrecks_navbox_footer"] = 10000, ["Shipwrecks_navbox_footer/link"] = 10000, ["Short_description"] = 5840000, ["Short_description/lowercasecheck"] = 5840000, ["Short_pages_monitor"] = 11000, ["Short_pages_monitor/maximum_length"] = 11000, ["Shortcut"] = 20000, ["Should_be_SVG"] = 8800, ["Shy"] = 2900, ["Sic"] = 33000, ["Sica"] = 3100, ["Side_box"] = 1190000, ["Sidebar"] = 264000, ["Sidebar_games_events"] = 38000, ["Sidebar_person"] = 2500, ["Sidebar_person/styles.css"] = 2500, ["Sidebar_with_collapsible_lists"] = 95000, ["Sigfig"] = 3900, ["Significant_figures"] = 5300, ["Significant_figures/rnd"] = 4900, ["Signpost-subscription"] = 2100, ["Signpost/item"] = 40000, ["Sildb_prim"] = 2100, ["Silver02"] = 17000, ["Silver2"] = 50000, ["Silver_medal"] = 5800, ["Similar_names"] = 2300, ["Single+double"] = 7700, ["Single+space"] = 15000, ["Single-innings_cricket_match"] = 3400, ["Single_chart"] = 38000, ["Single_chart/chartnote"] = 38000, ["Single_namespace"] = 205000, ["Singlechart"] = 19000, ["Singles"] = 43000, ["Sister-inline"] = 194000, ["Sister_project"] = 1060000, ["Sister_project_links"] = 11000, ["Sisterlinks"] = 2200, ["Skip_to_talk"] = 12000, ["Skip_to_talk/styles.css"] = 12000, ["Sky"] = 2700, ["Sky/styles.css"] = 2700, ["Slink"] = 19000, ["Small"] = 615000, ["Small_Solar_System_bodies"] = 3600, ["Smallcaps"] = 17000, ["Smallcaps/styles.css"] = 18000, ["Smallcaps_all"] = 2900, ["Smalldiv"] = 23000, ["Smaller"] = 77000, ["Smallsup"] = 21000, ["Smiley"] = 45000, ["Snd"] = 188000, ["Snds"] = 6400, ["Soccer_icon"] = 129000, ["Soccer_icon2"] = 129000, ["Soccer_icon4"] = 5100, ["Soccerbase"] = 13000, ["Soccerbase_season"] = 7000, ["Soccerway"] = 78000, ["Sock"] = 49000, ["Sock_list"] = 5500, ["Sockcat"] = 2000, ["Sockmaster"] = 9600, ["Sockpuppet"] = 249000, ["Sockpuppet/altmaster"] = 2700, ["Sockpuppet/categorise"] = 249000, ["SockpuppetCheckuser"] = 5500, ["Sockpuppet_category"] = 47000, ["Sockpuppet_category/confirmed"] = 24000, ["Sockpuppet_category/suspected"] = 22000, ["Sockpuppetcheckuser"] = 3600, ["Sockpuppeteer"] = 25000, ["Soft_hyphen"] = 3000, ["Soft_redirect"] = 6000, ["Soft_redirect_protection"] = 8100, ["Softredirect"] = 3300, ["Solar_luminosity"] = 4500, ["Solar_mass"] = 5400, ["Solar_radius"] = 4400, ["Soldier_icon"] = 3900, ["Soldier_icon2"] = 3900, ["Songs"] = 2100, ["Songs_category"] = 8700, ["Songs_category/core"] = 8700, ["Sort"] = 102000, ["Sortname"] = 54000, ["Source-attribution"] = 30000, ["Source_check"] = 960000, ["Sourcecheck"] = 960000, ["Sources"] = 3200, ["Sources_exist"] = 2200, ["South_America_topic"] = 2500, ["Sp"] = 171000, ["Space"] = 56000, ["Space+double"] = 19000, ["Space+single"] = 13000, ["Spaced_en_dash"] = 220000, ["Spaced_en_dash_space"] = 6400, ["Spaced_ndash"] = 22000, ["Spaces"] = 582000, ["Spain_metadata_Wikidata"] = 7500, ["Spamlink"] = 13000, ["Species_Latin_name_abbreviation_disambiguation"] = 2200, ["Species_list"] = 16000, ["Speciesbox"] = 314000, ["Speciesbox/getGenus"] = 314000, ["Speciesbox/getSpecies"] = 314000, ["Speciesbox/name"] = 314000, ["Speciesbox/parameterCheck"] = 314000, ["Speciesbox/trim"] = 314000, ["Specieslist"] = 6300, ["Split_article"] = 3800, ["Spnd"] = 4300, ["Sport_icon"] = 14000, ["Sport_icon2"] = 15000, ["SportsYearCatUSstate"] = 6500, ["SportsYearCatUSstate/core"] = 6500, ["Sports_links"] = 69000, ["Sports_reference"] = 6700, ["Squad_maintenance"] = 3600, ["Sronly"] = 42000, ["Srt"] = 5700, ["Stack"] = 26000, ["Stack/styles.css"] = 35000, ["Stack_begin"] = 9500, ["Stack_end"] = 9500, ["StaleIP"] = 3300, ["Standings_table_end"] = 56000, ["Standings_table_entry"] = 56000, ["Standings_table_entry/record"] = 56000, ["Standings_table_start"] = 56000, ["Standings_table_start/colheader"] = 56000, ["Standings_table_start/colspan"] = 56000, ["Standings_table_start/styles.css"] = 56000, ["Starbox_astrometry"] = 5200, ["Starbox_begin"] = 5400, ["Starbox_catalog"] = 5300, ["Starbox_character"] = 5200, ["Starbox_detail"] = 5100, ["Starbox_end"] = 5300, ["Starbox_image"] = 3000, ["Starbox_observe"] = 5200, ["Starbox_reference"] = 5300, ["Start-Class"] = 18000, ["Start-date"] = 3700, ["Start_and_end_dates"] = 2800, ["Start_box"] = 7500, ["Start_date"] = 449000, ["Start_date_and_age"] = 150000, ["Start_date_and_years_ago"] = 6000, ["Start_date_text"] = 3800, ["Start_of_course_timeline"] = 5900, ["Start_of_course_week"] = 6000, ["Start_tab"] = 5300, ["Startflatlist"] = 147000, ["Static_IP"] = 5500, ["Station"] = 8000, ["Station_link"] = 16000, ["Stdinchicite"] = 11000, ["Steady"] = 15000, ["Stl"] = 14000, ["Stn"] = 7600, ["Stn_art_lnk"] = 2100, ["Stnlnk"] = 31000, ["Storm_colour"] = 5200, ["Storm_name"] = 2100, ["Storm_path"] = 2100, ["StoryTeleplay"] = 3600, ["Str_count"] = 5800, ["Str_endswith"] = 209000, ["Str_find"] = 279000, ["Str_index"] = 13000, ["Str_left"] = 930000, ["Str_len"] = 21000, ["Str_letter"] = 177000, ["Str_letter/trim"] = 20000, ["Str_number"] = 8000, ["Str_number/trim"] = 187000, ["Str_rep"] = 269000, ["Str_trim"] = 5000, ["Str_≠_len"] = 37000, ["Str_≥_len"] = 79000, ["Strfind_short"] = 236000, ["Strikethrough"] = 17000, ["String_split"] = 6300, ["Strip_tags"] = 38000, ["Strong"] = 902000, ["Structurae"] = 2100, ["Stub-Class"] = 18000, ["Stub_Category"] = 13000, ["Stub_category"] = 18000, ["Stub_documentation"] = 37000, ["Student_editor"] = 27000, ["Student_sandbox"] = 4500, ["Student_table_row"] = 5700, ["Students_table"] = 5700, ["Su"] = 10000, ["Su-census1989"] = 4400, ["Sub"] = 5200, ["Subinfobox_bodystyle"] = 36000, ["Subject_bar"] = 17000, ["Suboff"] = 6500, ["Subon"] = 6600, ["Subpage_other"] = 307000, ["Subscription"] = 4200, ["Subscription_required"] = 33000, ["Subsidebar_bodystyle"] = 6200, ["Subst_only"] = 5300, ["Substituted_comment"] = 19000, ["Succession_box"] = 118000, ["Succession_box/check"] = 118000, ["Succession_links"] = 183000, ["Summer_Olympics_by_year_category_navigation"] = 2400, ["Summer_Olympics_by_year_category_navigation/core"] = 2400, ["Sunday"] = 2700, ["Sup"] = 60000, ["Suppress_categories"] = 5500, ["Surname"] = 69000, ["Swiss_populations"] = 2400, ["Swiss_populations_NC"] = 3000, ["Swiss_populations_YM"] = 2300, ["Swiss_populations_ref"] = 2400, ["Switcher"] = 4000, ["Module:SDcat"] = 5730000, ["Module:SPI_archive_notice"] = 34000, ["Module:Science_redirect"] = 268000, ["Module:Science_redirect/conf"] = 268000, ["Module:Section_link"] = 70000, ["Module:Section_sizes"] = 4200, ["Module:See_also_if_exists"] = 76000, ["Module:Self"] = 46000, ["Module:Self/license_migration_data.json"] = 22000, ["Module:Self/styles.css"] = 46000, ["Module:Separated_entries"] = 2360000, ["Module:Series_overview"] = 8200, ["Module:Settlement_short_description"] = 713000, ["Module:Shortcut"] = 24000, ["Module:Shortcut/config"] = 24000, ["Module:Shortcut/styles.css"] = 24000, ["Module:Side_box"] = 1220000, ["Module:Side_box/styles.css"] = 1220000, ["Module:Sidebar"] = 346000, ["Module:Sidebar/configuration"] = 346000, ["Module:Sidebar/styles.css"] = 352000, ["Module:Sidebar_games_events"] = 38000, ["Module:Sidebar_games_events/styles.css"] = 38000, ["Module:Singles"] = 43000, ["Module:Sister_project_links"] = 15000, ["Module:Sister_project_links/bar/styles.css"] = 3800, ["Module:Sister_project_links/styles.css"] = 11000, ["Module:Sock_list"] = 5500, ["Module:Sort_title"] = 20000, ["Module:Sortkey"] = 203000, ["Module:Split_article"] = 3800, ["Module:Sports_career"] = 19000, ["Module:Sports_color"] = 69000, ["Module:Sports_color/baseball"] = 34000, ["Module:Sports_color/basketball"] = 23000, ["Module:Sports_color/ice_hockey"] = 3200, ["Module:Sports_rbr_table"] = 12000, ["Module:Sports_rbr_table/styles.css"] = 12000, ["Module:Sports_reference"] = 6700, ["Module:Sports_results"] = 15000, ["Module:Sports_results/styles.css"] = 9800, ["Module:Sports_table"] = 60000, ["Module:Sports_table/Volleyball"] = 2000, ["Module:Sports_table/WDL"] = 53000, ["Module:Sports_table/WDL_OT"] = 2900, ["Module:Sports_table/WL"] = 4300, ["Module:Sports_table/WL_OT"] = 2200, ["Module:Sports_table/argcheck"] = 60000, ["Module:Sports_table/styles.css"] = 60000, ["Module:Sports_table/sub"] = 61000, ["Module:Sports_table/totalscheck"] = 44000, ["Module:Stock_tickers/NYSE"] = 2000, ["Module:Storm_categories"] = 5300, ["Module:Storm_categories/categories"] = 5300, ["Module:Storm_categories/colors"] = 5300, ["Module:Storm_categories/icons"] = 5300, ["Module:String"] = 9910000, ["Module:String2"] = 4710000, ["Module:Su"] = 12000, ["Module:Subject_bar"] = 17000, ["Module:Suppress_categories"] = 5500, } 5c6fed328e89ac4fd7b6fa54fde5bc857b599a5a Main Page 0 1 1 2024-04-02T21:27:16Z MediaWiki default 1 Welcome to Miraheze! wikitext text/x-wiki __NOTOC__ == Welcome to {{SITENAME}}! == This Main Page was created automatically and it seems it hasn't been replaced yet. === For the bureaucrat(s) of this wiki === Hello, and welcome to your new wiki! Thank you for choosing Miraheze for the hosting of your wiki, we hope you will enjoy our hosting. You can immediately start working on your wiki or whenever you want. Need help? No problem! We will help you with your wiki as needed. To start, try checking out these helpful links: * [[mw:Special:MyLanguage/Help:Contents|MediaWiki guide]] (e.g. navigation, editing, deleting pages, blocking users) * [[meta:Special:MyLanguage/FAQ|Miraheze FAQ]] * [[meta:Special:MyLanguage/Request features|Request settings changes on your wiki]]. (Extensions, Skin and Logo/Favicon changes should be done through [[Special:ManageWiki]] on your wiki, see [[meta:Special:MyLanguage/ManageWiki|ManageWiki]] for more information.) ==== I still don't understand X! ==== Well, that's no problem. Even if something isn't explained in the documentation/FAQ, we are still happy to help you. You can find us here: * [[meta:Special:MyLanguage/Help center|On our own Miraheze wiki]] * On [[phorge:|Phorge]] * On [https://miraheze.org/discord Discord] * On IRC in #miraheze on irc.libera.chat ([irc://irc.libera.chat/%23miraheze direct link]; [https://web.libera.chat/?channel=#miraheze webchat]) === For visitors of this wiki === Hello, the default Main Page of this wiki (this page) has not yet been replaced by the bureaucrat(s) of this wiki. The bureaucrat(s) might still be working on a Main Page, so please check again later! 070d9e6457eab136df99905438a1f57c037772b0 File:Logo.svg 6 2 2 2024-04-02T22:21:54Z Nulcow 2 Site logo wikitext text/x-wiki == Summary == Site logo 8cd23b2481915920e1445d593ae9bdd803809173 File:Favicon.png 6 3 3 2024-04-02T22:30:17Z Nulcow 2 Site logo favicon wikitext text/x-wiki == Summary == Site logo favicon 21ee00644540d9f5df5338db9a6cf717d2f6f8e7 Template:Subreddit 10 4 4 2024-04-02T22:44:48Z Nulcow 2 Created page with "[https://www.reddit.com/r/{{{1|all}}} r/{{{1|all}}}]" wikitext text/x-wiki [https://www.reddit.com/r/{{{1|all}}} r/{{{1|all}}}] 5bbd60d30107a83d07e824127bb753341726e10f Main Page 0 1 5 1 2024-04-02T22:54:19Z Nulcow 2 wikitext text/x-wiki __NOTOC__ == Welcome to {{SITENAME}}! == Rulepedia is the 196 encyclopedia that anyone can edit. == What is 196? == "196" refers to an online community that started in the shitposting subreddit {{Subreddit|196}}, and has since spread to other parts of teh interwebz, such as #196 on Tumblr. The one "rule" of r/196 is that you have to post once before you leave. Although there's only 1 true rule, the 196 community still has a few unwritten rules we expect each other to follow. Quoted verbatim from the sidebar: <blockquote> ...our unwritten rules are mostly a vibe check. If you don't pass the vibe check we'll probably call you a nerd. Extremely uncool behavior will probably get you a brickin' (ban). If you post in certain subreddits you've most likely already failed the vibe check. Context clues below should help you figure out which ones, so without further ado if you still don't know what the vibe check entails, this subreddit is: ✅ ACAB (and we especially mean the one you know personally) ✅ Antifascist ✅ BLM ✅ LGBTQIA+ and allies ✅ Trans rights (it's one of our default flairs!) ✅ Full of femboys and bottom energy tbh ❌ Bigots ❌ Bootlickers ❌ Conservatives ❌ Cops (we hate cops so goddamn much it's unreal) ❌ Landlords ❌ Nazis ❌ Tankies ❌ Tate, Peterson, Rogan, et al., as well as their defenders and downplayers ❌ The French (this is mostly a joke) Yes, this IS a safe space and failure to pass this vibe check will absolutely result in a permanent ban. We don't care for your devil's advocacy or JAQing off, and we look forward to your inevitable post bitching about us on justunsubbed. </blockquote> 040b3058e33370f7407461e542e7ee11c6441ac5 6 5 2024-04-02T23:16:29Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #0000000c; padding: 12px"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> Rulepedia is the 196 encyclopedia that anyone can edit. == What is (r/)196? == "196" refers to an online community that started in the shitposting subreddit {{Subreddit|196}}, and has since spread to other parts of teh interwebz, such as #196 on Tumblr. The one "rule" of r/196 is that you have to post once before you leave. Although there's only 1 true rule, there are still a few unwritten rules 196ers are expected to follow. Reading the sidebar of r/196 should give you a good idea of what we're about. == About the Wiki == Most things which apply to the subreddit also apply to {{SITENAME}}. Note that in addition to the awesome r/196 rules, you must also follow Miraheze's (somewhat reasonable) global content policy. </td> </tr> </table> aab992295c31f65ce6d3fe99a4d1016549d44801 7 6 2024-04-02T23:20:14Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> Rulepedia is the 196 encyclopedia that anyone can edit. === What is (r/)196? === "196" refers to an online community that started in the shitposting subreddit {{Subreddit|196}}, and has since spread to other parts of teh interwebz, such as #196 on Tumblr. The one "rule" of r/196 is that you have to post once before you leave. Although there's only 1 true rule, there are still a few unwritten rules 196ers are expected to follow. Reading the sidebar of r/196 should give you a good idea of what we're about. === About the Wiki === Most things which apply to the subreddit also apply to {{SITENAME}}. Note that in addition to the awesome r/196 rules, you must also follow Miraheze's (somewhat reasonable) global content policy. </td> </tr> </table> 8d26cde3a3f6033c0abb8ab0e5720ed4951a5754 9 7 2024-04-02T23:30:59Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px; padding-bottom: 0; width: 100%;"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> <center> Rulepedia is the 196 encyclopedia that anyone can edit. We currently have {{NUMBEROFARTICLES}} articles, and people like you are adding more every day! [ [[Rulepedia:About|Learn more]] ] </td> </center> </tr> </table> 23e0fccab4777d9ac167c76f2392f0802a5edb37 29 9 2024-04-03T03:11:33Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px; padding-bottom: 0; width: 100%;"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> <center> Rulepedia is the 196 encyclopedia that anyone can edit. We currently have {{NUMBEROFARTICLES}} articles, and people like you are adding more every day! [ [[Rulepedia:About|Learn more]] ] </td> </center> </tr> </table> <br> <table style="background-color: #ffcccc; border: 1px solid #ddaaaa; float: left; width: calc(50% - 8px); margin-right: 8px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #ddaaaa;">Featured</th> </tr> <tr> <td></td> </tr> <tr> <th style="border-bottom: 1px solid #ddaaaa;">What's new</th> </tr> <tr> <td> ''Coming soon...'' </td> </tr> </table> <table style="background-color: #bbddff; border: 1px solid #88bbdd; float: right; width: calc(50% - 4px); margin-left: 4px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #88aadd;">Articles of Awesome</th> </tr> <tr> <td> These are articles which are high-quality and/or about important 196-related topics. If there's an important topic here that doesn't have an article, write one for it! * [[r/196]] * [[Spronkus Kronkus]] * [[Rule]] * [[Big Floppa]] * [[List of 196 phenomena]] * [[List of notable 196ers]] </td> </tr> <tr> <th style="border-bottom: 1px solid #88aadd;">More 196</th> </tr> <tr> <td> Looking for places to chat and shitpost with other 196ers? We've got you covered! * {{Subreddit|196}} (subreddit) * [https://www.tumblr.com/tagged/196 #196 on Tumblr] * [https://cohost.org/rc/tagged/196 #196 on Cohost] </td> </tr> </table> 1eba388aaadb1ec96f3046646988f5472f936a40 33 29 2024-04-03T15:57:32Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px; padding-bottom: 0; width: 100%;"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> <center> Rulepedia is the 196 encyclopedia that anyone can edit. We currently have {{NUMBEROFARTICLES}} articles, and people like you are adding more every day! [ [[Rulepedia:About|Learn more]] ] </td> </center> </tr> </table> <br> <table style="background-color: #ffcccc; border: 1px solid #ddaaaa; float: left; width: calc(50% - 8px); margin-right: 8px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #ddaaaa;">Featured</th> </tr> <tr> <td></td> </tr> <tr> <th style="border-bottom: 1px solid #ddaaaa;">What's new</th> </tr> <tr> <td> ''Coming soon...'' </td> </tr> </table> <table style="background-color: #bbddff; border: 1px solid #88bbdd; float: right; width: calc(50% - 4px); margin-left: 4px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #88aadd;">Articles of Awesome</th> </tr> <tr> <td> These are articles which are high-quality and/or about important 196-related topics. If there's an important topic here that doesn't have an article, write one for it! * [[r/196]], the 196 subreddit * [[Spronkus Kronkus]], the recognisable cartoon character who says "trans rights" and shoots fascists * [[Rule]], the one rule of r/196 * [[Big Floppa]], great kitby, partner of Spronkus * [[List of 196 phenomena]] * [[List of notable 196ers]] </td> </tr> <tr> <th style="border-bottom: 1px solid #88aadd;">More 196</th> </tr> <tr> <td> Looking for places to chat and shitpost with other 196ers? We've got you covered! * {{Subreddit|196}} (subreddit) * [https://www.tumblr.com/tagged/196 #196 on Tumblr] * [https://cohost.org/rc/tagged/196 #196 on Cohost] </td> </tr> </table> b1378f73c621f2d155da01eec17cfb04bfa585d9 34 33 2024-04-03T16:22:10Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px; padding-bottom: 0; width: 100%;"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> <center> Rulepedia is the 196 encyclopedia that anyone can edit. We currently have {{NUMBEROFARTICLES}} articles, and people like you are adding more every day! [ [[Rulepedia:About|Learn more]] ] </td> </center> </tr> </table> <br> <table style="background-color: #ffcccc; border: 1px solid #ddaaaa; float: left; width: calc(50% - 8px); margin-right: 8px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #ddaaaa;">Featured</th> </tr> <tr> <td>{{Template:Featured}}</td> </tr> <tr> <th style="border-bottom: 1px solid #ddaaaa;">What's new</th> </tr> <tr> <td> ''Coming soon...'' </td> </tr> </table> <table style="background-color: #bbddff; border: 1px solid #88bbdd; float: right; width: calc(50% - 4px); margin-left: 4px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #88aadd;">Articles of Awesome</th> </tr> <tr> <td> These are articles which are high-quality and/or about important 196-related topics. If there's an important topic here that doesn't have an article, write one for it! * [[r/196]], the 196 subreddit * [[Spronkus Kronkus]], the recognisable cartoon character who says "trans rights" and shoots fascists * [[Rule]], the one rule of r/196 * [[Big Floppa]], great kitby, partner of Spronkus * [[List of 196 phenomena]] * [[List of notable 196ers]] </td> </tr> <tr> <th style="border-bottom: 1px solid #88aadd;">More 196</th> </tr> <tr> <td> Looking for places to chat and shitpost with other 196ers? We've got you covered! * {{Subreddit|196}} (subreddit) * [https://www.tumblr.com/tagged/196 #196 on Tumblr] * [https://cohost.org/rc/tagged/196 #196 on Cohost] </td> </tr> </table> f53cee1b54144cc73ad88defbe30690d30500983 38 34 2024-04-03T16:37:39Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px; padding-bottom: 0; width: 100%;"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> <center> Rulepedia is the 196 encyclopedia that anyone can edit. We currently have {{NUMBEROFARTICLES}} articles, and people like you are adding more every day! [ [[Rulepedia:About|Learn more]] ] </td> </center> </tr> </table> <br> <table style="background-color: #ffcccc; border: 1px solid #ddaaaa; float: left; width: calc(50% - 8px); margin-right: 8px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #ddaaaa;">Featured</th> </tr> <tr> <td>{{#ifexpr:{{formatnum:{{PAGESIZE:Wikipedia:Today's featured article/{{#time:F j, Y}}}}|R}}>150|{{Wikipedia:Today's featured article/{{#time:F j, Y}}}}|{{Rulepedia:Featured Article/{{#time:F j, Y|-1 day}}}}}}</td> </tr> <tr> <th style="border-bottom: 1px solid #ddaaaa;">What's new</th> </tr> <tr> <td> ''Coming soon...'' </td> </tr> </table> <table style="background-color: #bbddff; border: 1px solid #88bbdd; float: right; width: calc(50% - 4px); margin-left: 4px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #88aadd;">Articles of Awesome</th> </tr> <tr> <td> These are articles which are high-quality and/or about important 196-related topics. If there's an important topic here that doesn't have an article, write one for it! * [[r/196]], the 196 subreddit * [[Spronkus Kronkus]], the recognisable cartoon character who says "trans rights" and shoots fascists * [[Rule]], the one rule of r/196 * [[Big Floppa]], great kitby, partner of Spronkus * [[List of 196 phenomena]] * [[List of notable 196ers]] </td> </tr> <tr> <th style="border-bottom: 1px solid #88aadd;">More 196</th> </tr> <tr> <td> Looking for places to chat and shitpost with other 196ers? We've got you covered! * {{Subreddit|196}} (subreddit) * [https://www.tumblr.com/tagged/196 #196 on Tumblr] * [https://cohost.org/rc/tagged/196 #196 on Cohost] </td> </tr> </table> 0b09ced4b8c61afd7c21160a16d4550aa5019eeb 43 38 2024-04-03T16:43:22Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px; padding-bottom: 0; width: 100%;"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> <center> Rulepedia is the 196 encyclopedia that anyone can edit. We currently have {{NUMBEROFARTICLES}} articles, and people like you are adding more every day! [ [[Rulepedia:About|Learn more]] ] </td> </center> </tr> </table> <br> <table style="background-color: #ffcccc; border: 1px solid #ddaaaa; float: left; width: calc(50% - 8px); margin-right: 8px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #ddaaaa;">Featured</th> </tr> <tr> <td>{{#ifexpr:{{formatnum:{{PAGESIZE:Rulepedia:Featured Article/{{#time:F j, Y}}}}|R}}>150|{{Rulepedia:Featured Article/{{#time:F j, Y}}}}|{{Rulepedia:Featured Article/{{#time:F j, Y|-1 day}}}}}}</td> </tr> <tr> <th style="border-bottom: 1px solid #ddaaaa;">What's new</th> </tr> <tr> <td> ''Coming soon...'' </td> </tr> </table> <table style="background-color: #bbddff; border: 1px solid #88bbdd; float: right; width: calc(50% - 4px); margin-left: 4px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #88aadd;">Articles of Awesome</th> </tr> <tr> <td> These are articles which are high-quality and/or about important 196-related topics. If there's an important topic here that doesn't have an article, write one for it! * [[r/196]], the 196 subreddit * [[Spronkus Kronkus]], the recognisable cartoon character who says "trans rights" and shoots fascists * [[Rule]], the one rule of r/196 * [[Big Floppa]], great kitby, partner of Spronkus * [[List of 196 phenomena]] * [[List of notable 196ers]] </td> </tr> <tr> <th style="border-bottom: 1px solid #88aadd;">More 196</th> </tr> <tr> <td> Looking for places to chat and shitpost with other 196ers? We've got you covered! * {{Subreddit|196}} (subreddit) * [https://www.tumblr.com/tagged/196 #196 on Tumblr] * [https://cohost.org/rc/tagged/196 #196 on Cohost] </td> </tr> </table> f236a9bafe94d9a46aaa05341117d77dd8521bef Rulepedia:About 4 5 8 2024-04-02T23:21:59Z Nulcow 2 Created page with "=== What is (r/)196? === "196" refers to an online community that started in the shitposting subreddit {{Subreddit|196}}, and has since spread to other parts of teh interwebz, such as #196 on Tumblr. The one "rule" of r/196 is that you have to post once before you leave. Although there's only 1 true rule, there are still a few unwritten rules 196ers are expected to follow. Reading the sidebar of r/196 should give you a good idea of what we're about. === About the Wiki..." wikitext text/x-wiki === What is (r/)196? === "196" refers to an online community that started in the shitposting subreddit {{Subreddit|196}}, and has since spread to other parts of teh interwebz, such as #196 on Tumblr. The one "rule" of r/196 is that you have to post once before you leave. Although there's only 1 true rule, there are still a few unwritten rules 196ers are expected to follow. Reading the sidebar of r/196 should give you a good idea of what we're about. === About the Wiki === Most things which apply to the subreddit also apply to {{SITENAME}}. Note that in addition to the awesome r/196 rules, you must also follow Miraheze's (somewhat reasonable) global content policy. 538f570e0b9aaac5b04521f5713cfc098dc24edd MediaWiki:Monobook.css 8 6 10 2024-04-03T00:38:05Z Nulcow 2 Created page with "body, body.skin--responsive { background: #cee3f8; font-family: Verdana, Tahoma, sans-serif; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 9px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 9px; } .mw-body, .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { border: 1px s..." css text/css body, body.skin--responsive { background: #cee3f8; font-family: Verdana, Tahoma, sans-serif; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 9px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 9px; } .mw-body, .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { border: 1px solid #5f99cf; } #p-cations li, body.skin--responsive #p-cactions li { border-color: transparent; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 4px); } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 2em; padding: 4px; padding-bottom: 0; border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } 7a2371c249f116c507b7baec3199e1b26c792cfe 11 10 2024-04-03T01:13:57Z Nulcow 2 css text/css body, body.skin--responsive { background: #cee3f8; font-family: Verdana, Tahoma, sans-serif; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 9px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 9px; } .mw-body, .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { border: 1px solid #5f99cf; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 15051b0a814342f1d3fa0168f9c8357100bb79fd 12 11 2024-04-03T01:29:24Z Nulcow 2 css text/css body, body.skin--responsive { background: #cee3f8; font-family: Verdana, Tahoma, sans-serif; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } .mw-body { border: 1px solid #5f99cf; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-one, body.skin--responsive #column-one { height: 100%; } #sidebar { background: #ffffff; height: 100%; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 27afe44227ff7c2ba67b848660c477840ad35acd 13 12 2024-04-03T02:05:03Z Nulcow 2 css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } #globalWrapper { margin-top: 400px; } .mw-body { border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-one, body.skin--responsive #column-one { min-height: max-content; } #sidebar { background: #ffffff; min-height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } b005baf6b8d4e15bdfe2579596938b005114d4e7 14 13 2024-04-03T02:05:30Z Nulcow 2 css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } /* #globalWrapper { margin-top: 400px; }*/ .mw-body { border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-one, body.skin--responsive #column-one { min-height: max-content; } #sidebar { background: #ffffff; min-height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } de2c2cf9524d257d393298c80b0809f7d08aefa9 15 14 2024-04-03T02:05:56Z Nulcow 2 css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } .mw-body { border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-one, body.skin--responsive #column-one { min-height: max-content; } #sidebar { background: #ffffff; min-height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 7e0b2374750ff85f3fc8d666d7ca8ecfde0fd9f7 16 15 2024-04-03T02:12:21Z Nulcow 2 css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } .mw-body, body.skin--responsive .mw-body { border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-one, body.skin--responsive #column-one { width: 12.2em; min-height: max-content; } #sidebar { background: #ffffff; height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 0b035aef1c0f083cd07a6aed8f7c46aad16cb833 17 16 2024-04-03T02:13:56Z Nulcow 2 css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } .mw-body, body.skin--responsive .mw-body { min-height: 100%; border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-one, body.skin--responsive #column-one { width: 12.2em; min-height: max-content; } #sidebar { background: #ffffff; height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 1aa1ce0584593045eafc66a585fa6979c025825b 18 17 2024-04-03T02:16:46Z Nulcow 2 css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } .mw-body, body.skin--responsive .mw-body { min-height: 100%; border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-content, body.skin--responsive #column-content { min-height: 100%; } #column-one, body.skin--responsive #column-one { width: 12.2em; min-height: max-content; } #sidebar { background: #ffffff; height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 1479f7a24cf5615e7f276ea78877a4e8220c42bd 19 18 2024-04-03T02:23:38Z Nulcow 2 css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } .mw-body, body.skin--responsive .mw-body { min-height: 100%; border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; padding: 8px 0; border-bottom: none; border-top-color: #5f99cf; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-content, body.skin--responsive #column-content { min-height: 100%; } #column-one, body.skin--responsive #column-one { width: 12.2em; min-height: max-content; } #sidebar { background: #ffffff; height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 0c9825306a9d6e9a652b981137b39f2fe7c03710 30 19 2024-04-03T15:53:05Z Nulcow 2 Nulcow moved page [[MediaWiki:Common.css]] to [[MediaWiki:MonoBook.css]] without leaving a redirect: This CSS only applies to MonoBook css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } .mw-body, body.skin--responsive .mw-body { min-height: 100%; border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; padding: 8px 0; border-bottom: none; border-top-color: #5f99cf; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-content, body.skin--responsive #column-content { min-height: 100%; } #column-one, body.skin--responsive #column-one { width: 12.2em; min-height: max-content; } #sidebar { background: #ffffff; height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 0c9825306a9d6e9a652b981137b39f2fe7c03710 31 30 2024-04-03T15:54:35Z Nulcow 2 Nulcow moved page [[MediaWiki:MonoBook.css]] to [[MediaWiki:Monobook.css]]: Misspelled title css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } .mw-body, body.skin--responsive .mw-body { min-height: 100%; border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; padding: 8px 0; border-bottom: none; border-top-color: #5f99cf; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; border-left: none; border-right: none; border-bottom: none; } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } #column-content, body.skin--responsive #column-content { min-height: 100%; } #column-one, body.skin--responsive #column-one { width: 12.2em; min-height: max-content; } #sidebar { background: #ffffff; height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; } #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } 0c9825306a9d6e9a652b981137b39f2fe7c03710 Module:Excerpt 828 7 20 2024-04-03T02:57:46Z Nulcow 2 Created page with "-- Module:Excerpt implements the Excerpt template -- Documentation and master version: https://en.wikipedia.org/wiki/Module:Excerpt -- Authors: User:Sophivorus, User:Certes, User:Aidan9382 & others -- License: CC-BY-SA-3.0 local Transcluder = require( 'Module:Transcluder' ) local yesno = require( 'Module:Yesno' ) local ok, config = pcall( require, 'Module:Excerpt/config' ) if not ok then config = {} end local p = {} -- Helper function to get arguments local args loc..." Scribunto text/plain -- Module:Excerpt implements the Excerpt template -- Documentation and master version: https://en.wikipedia.org/wiki/Module:Excerpt -- Authors: User:Sophivorus, User:Certes, User:Aidan9382 & others -- License: CC-BY-SA-3.0 local Transcluder = require( 'Module:Transcluder' ) local yesno = require( 'Module:Yesno' ) local ok, config = pcall( require, 'Module:Excerpt/config' ) if not ok then config = {} end local p = {} -- Helper function to get arguments local args local function getArg( key, default ) local value = args[ key ] if value and mw.text.trim( value ) ~= '' then return value end return default end -- Helper function to handle errors local function getError( message, value ) if type( message ) == 'string' then message = Transcluder.getError( message, value ) end if config.categories and config.categories.errors and mw.title.getCurrentTitle().isContentPage then message:node( '[[Category:' .. config.categories.errors .. ']]' ) end return message end -- Helper function to get localized messages local function getMessage( key ) local ok, TNT = pcall( require, 'Module:TNT' ) if not ok then return key end return TNT.format( 'I18n/Module:Excerpt.tab', key ) end -- Main entry point for templates function p.main( frame ) args = Transcluder.parseArgs( frame ) -- Make sure the requested page exists local page = getArg( 1 ) if not page or page == '{{{1}}}' then return getError( 'no-page' ) end local title = mw.title.new(page) if not title then return getError( 'invalid-title', page ) end if title.isRedirect then title = title.redirectTarget end if not title.exists then return getError( 'page-not-found', page ) end page = title.prefixedText -- Set variables from the template parameters local section = getArg( 2, mw.ustring.match( getArg( 1 ), '[^#]+#(.+)' ) ) local hat = yesno( getArg( 'hat', true ) ) local edit = yesno( getArg( 'edit', true ) ) local this = getArg( 'this' ) local only = getArg( 'only' ) local files = getArg( 'files', getArg( 'file', ( only == 'file' and 1 ) ) ) local lists = getArg( 'lists', getArg( 'list', ( only == 'list' and 1 ) ) ) local tables = getArg( 'tables', getArg( 'table', ( only == 'table' and 1 ) ) ) local templates = getArg( 'templates', getArg( 'template', ( only == 'template' and 1 ) ) ) local paragraphs = getArg( 'paragraphs', getArg( 'paragraph', ( only == 'paragraph' and 1 ) ) ) local references = getArg( 'references' ) local subsections = not yesno( getArg( 'subsections' ) ) local noLinks = not yesno( getArg( 'links', true ) ) local noBold = not yesno( getArg( 'bold' ) ) local onlyFreeFiles = yesno( getArg( 'onlyfreefiles', true ) ) local briefDates = yesno( getArg( 'briefdates', false ) ) local inline = yesno( getArg( 'inline' ) ) local quote = yesno( getArg( 'quote' ) ) local more = yesno( getArg( 'more' ) ) local class = getArg( 'class' ) local displaytitle = getArg( 'displaytitle' ) or page -- Build the hatnote if hat and not inline then if this then hat = this elseif quote then hat = getMessage( 'this' ) elseif only then hat = getMessage( only ) else hat = getMessage( 'section' ) end hat = hat .. ' ' .. getMessage( 'excerpt' ) .. ' ' if section then hat = hat .. '[[:' .. page .. '#' .. mw.uri.anchorEncode( section ) .. '|' .. displaytitle .. ' § ' .. mw.ustring.gsub( section, '%[%[([^]|]+)|?[^]]*%]%]', '%1' ) .. ']].' -- remove nested links else hat = hat .. '[[:' .. page .. '|' .. displaytitle .. ']].' end if edit then hat = hat .. '<span class="mw-editsection-like plainlinks"><span class="mw-editsection-bracket">[</span>[' hat = hat .. title:fullUrl( 'action=edit' ) .. ' ' .. mw.message.new( 'editsection' ):plain() hat = hat .. ']<span class="mw-editsection-bracket">]</span></span>' end if config.hat then hat = config.hat .. hat .. '}}' hat = frame:preprocess( hat ) else hat = mw.html.create( 'div' ):addClass( 'dablink excerpt-hat' ):wikitext( hat ) end else hat = nil end -- Build the "Read more" link if more and not inline then more = "'''[[" .. page .. '#' .. ( section or '' ) .. "|" .. getMessage( 'more' ) .. "]]'''" more = mw.html.create( 'div' ):addClass( 'noprint excerpt-more' ):wikitext( more ) else more = nil end -- Build the options for Module:Transcluder out of the template parameters and the desired defaults local options = { files = files, lists = lists, tables = tables, paragraphs = paragraphs, sections = subsections, categories = 0, references = references, only = only and mw.text.trim( only, 's' ) .. 's', noLinks = noLinks, noBold = noBold, noSelfLinks = true, noNonFreeFiles = onlyFreeFiles, noBehaviorSwitches = true, fixReferences = true, linkBold = true, } -- Get the excerpt itself local title = page .. '#' .. ( section or '' ) local ok, excerpt = pcall( Transcluder.get, title, options ) if not ok then return getError( excerpt ) end if mw.text.trim( excerpt ) == '' and not only then if section then return getError( 'section-empty', section ) else return getError( 'lead-empty' ) end end -- Fix birth and death dates, but only in the first paragraph if briefDates then local startpos = 1 -- skip initial templates local s local e = 0 repeat startpos = e + 1 s, e = mw.ustring.find( excerpt, "%s*%b{}%s*", startpos ) until not s or s > startpos s, e = mw.ustring.find( excerpt, "%b()", startpos ) -- get (...), which may be (year–year) if s and s < startpos + 100 then -- look only near the start local year1, conjunction, year2 = mw.ustring.match( mw.ustring.sub( excerpt, s, e ), '(%d%d%d+)(.-)(%d%d%d+)' ) if year1 and year2 and (mw.ustring.match( conjunction, '[%-–—]' ) or mw.ustring.match( conjunction, '{{%s*[sS]nd%s*}}' )) then local y1 = tonumber(year1) local y2 = tonumber(year2) if y2 > y1 and y2 < y1 + 125 and y1 <= tonumber( os.date( "%Y" )) then excerpt = mw.ustring.sub( excerpt, 1, s ) .. year1 .. "–" .. year2 .. mw.ustring.sub( excerpt, e ) end end end end -- If no file was found, try to get one from the infobox local fileNamespaces = Transcluder.getNamespaces( 'File' ) if ( ( only == 'file' or only == 'files' ) or ( not only and ( files ~= '0' or not files ) ) ) and -- caller asked for files not Transcluder.matchAny( excerpt, '%[%[', fileNamespaces, ':' ) and -- and there are no files in Transcluder's output config.captions -- and we have the config option required to try finding files in templates then -- We cannot distinguish the infobox from the other templates so we search them all local infobox = Transcluder.getTemplates( excerpt ); infobox = table.concat( infobox ) local parameters = Transcluder.getParameters( infobox ) local file, captions, caption for _, pair in pairs( config.captions ) do file = pair[1] file = parameters[file] if file and Transcluder.matchAny( file, '^.*%.', { '[Jj][Pp][Ee]?[Gg]', '[Pp][Nn][Gg]', '[Gg][Ii][Ff]', '[Ss][Vv][Gg]' }, '.*' ) then file = mw.ustring.match( file, '%[?%[?.-:([^{|]+)%]?%]?' ) or file -- [[File:Example.jpg{{!}}upright=1.5]] to Example.jpg captions = pair[2] for _, p in pairs( captions ) do if parameters[ p ] then caption = parameters[ p ] break end end excerpt = '[[File:' .. file .. '|thumb|' .. ( caption or '' ) .. ']]' .. excerpt if ( onlyFreeFiles ) then excerpt = Transcluder.removeNonFreeFiles( excerpt ) end break end end end -- Unlike other elements, templates are filtered here -- because we had to search the infoboxes for files local trash if only and ( only == 'template' or only == 'templates' ) then trash, excerpt = Transcluder.getTemplates( excerpt, templates ); else -- Remove blacklisted templates local blacklist = config.blacklist and table.concat( config.blacklist, ',' ) or '' if templates then if string.sub( templates, 1, 1 ) == '-' then --Unwanted templates. Append to blacklist blacklist = templates .. ',' .. blacklist else --Wanted templates. Replaces blacklist and acts as whitelist blacklist = templates end else blacklist = '-' .. blacklist end trash, excerpt = Transcluder.getTemplates( excerpt, blacklist ); end -- Remove extra line breaks but leave one before and after so the parser interprets lists, tables, etc. correctly excerpt = mw.text.trim( excerpt ) excerpt = string.gsub( excerpt, '\n\n\n+', '\n\n' ) excerpt = '\n' .. excerpt .. '\n' -- Remove nested categories excerpt = frame:preprocess( excerpt ) local categories, excerpt = Transcluder.getCategories( excerpt, options.categories ) -- Add tracking categories if config.categories then local contentCategory = config.categories.content if contentCategory and mw.title.getCurrentTitle().isContentPage then excerpt = excerpt .. '[[Category:' .. contentCategory .. ']]' end local namespaceCategory = config.categories[ mw.title.getCurrentTitle().namespace ] if namespaceCategory then excerpt = excerpt .. '[[Category:' .. namespaceCategory .. ']]' end end -- Load the styles local styles if config.styles then styles = frame:extensionTag( 'templatestyles', '', { src = config.styles } ) end -- Combine and return the elements if inline then return mw.text.trim( excerpt ) end local tag = 'div' if quote then tag = 'blockquote' end excerpt = mw.html.create( 'div' ):addClass( 'excerpt' ):wikitext( excerpt ) local block = mw.html.create( tag ):addClass( 'excerpt-block' ):addClass( class ) return block:node( styles ):node( hat ):node( excerpt ):node( more ) end -- Entry points for backwards compatibility function p.lead( frame ) return p.main( frame ) end function p.excerpt( frame ) return p.main( frame ) end return p d491d72a159845544bd392e0b539938ad9368386 Module:Documentation 828 8 21 2024-04-03T03:00:17Z Nulcow 2 Created page with "-- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs local messageBox = require('Module:Message box') -- Get the config table. local cfg = mw.loadData('Module:Documentation/config') local i18n = mw.loadData('Module:Documentation/i18n') local p = {} -- Often-used functions. local ugsub = mw.ustring.gsub ---------------------------------------------------------------------------- -- Helper functions -..." Scribunto text/plain -- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs local messageBox = require('Module:Message box') -- Get the config table. local cfg = mw.loadData('Module:Documentation/config') local i18n = mw.loadData('Module:Documentation/i18n') local p = {} -- Often-used functions. local ugsub = mw.ustring.gsub ---------------------------------------------------------------------------- -- Helper functions -- -- These are defined as local functions, but are made available in the p -- table for testing purposes. ---------------------------------------------------------------------------- local function message(cfgKey, valArray, expectType) --[[ -- Gets a message from the cfg table and formats it if appropriate. -- The function raises an error if the value from the cfg table is not -- of the type expectType. The default type for expectType is 'string'. -- If the table valArray is present, strings such as $1, $2 etc. in the -- message are substituted with values from the table keys [1], [2] etc. -- For example, if the message "foo-message" had the value 'Foo $2 bar $1.', -- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz." --]] local msg = cfg[cfgKey] expectType = expectType or 'string' if type(msg) ~= expectType then error(require('Module:TNT').format('I18n/Documentation', 'cfg-error-msg-type', cfgKey, expectType, type(msg)), 2) end if not valArray then return msg end local function getMessageVal(match) match = tonumber(match) return valArray[match] or error(require('Module:TNT').format('I18n/Documentation', 'cfg-error-msg-empty', '$' .. match, cfgKey), 4) end local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal) return ret end p.message = message local function makeWikilink(page, display) if display then return mw.ustring.format('[[%s|%s]]', page, display) else return mw.ustring.format('[[%s]]', page) end end p.makeWikilink = makeWikilink local function makeCategoryLink(cat, sort) local catns = mw.site.namespaces[14].name return makeWikilink(catns .. ':' .. cat, sort) end p.makeCategoryLink = makeCategoryLink local function makeUrlLink(url, display) return mw.ustring.format('[%s %s]', url, display) end p.makeUrlLink = makeUrlLink local function makeToolbar(...) local ret = {} local lim = select('#', ...) if lim < 1 then return nil end for i = 1, lim do ret[#ret + 1] = select(i, ...) end return '<small style="font-style: normal;">(' .. table.concat(ret, ' &#124; ') .. ')</small>' end p.makeToolbar = makeToolbar ---------------------------------------------------------------------------- -- Argument processing ---------------------------------------------------------------------------- local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame, { valueFunc = function (key, value) if type(value) == 'string' then value = value:match('^%s*(.-)%s*$') -- Remove whitespace. if key == 'heading' or value ~= '' then return value else return nil end else return value end end }) return p[funcName](args) end end ---------------------------------------------------------------------------- -- Load TemplateStyles ---------------------------------------------------------------------------- p.main = function(frame) local parent = frame.getParent(frame) local output = p._main(parent.args) return frame:extensionTag{ name='templatestyles', args = { src= message('templatestyles-scr') } } .. output end ---------------------------------------------------------------------------- -- Main function ---------------------------------------------------------------------------- function p._main(args) --[[ -- This function defines logic flow for the module. -- @args - table of arguments passed by the user -- -- Messages: -- 'main-div-id' --> 'template-documentation' -- 'main-div-classes' --> 'template-documentation iezoomfix' --]] local env = p.getEnvironment(args) local root = mw.html.create() root :wikitext(p._getModuleWikitext(args, env)) :wikitext(p.protectionTemplate(env)) :wikitext(p.sandboxNotice(args, env)) -- This div tag is from {{documentation/start box}}, but moving it here -- so that we don't have to worry about unclosed tags. :tag('div') :attr('id', message('main-div-id')) :addClass(message('main-div-class')) :wikitext(p._startBox(args, env)) :wikitext(p._content(args, env)) :done() :wikitext(p._endBox(args, env)) :wikitext(p.addTrackingCategories(env)) return tostring(root) end ---------------------------------------------------------------------------- -- Environment settings ---------------------------------------------------------------------------- function p.getEnvironment(args) --[[ -- Returns a table with information about the environment, including title objects and other namespace- or -- path-related data. -- @args - table of arguments passed by the user -- -- Title objects include: -- env.title - the page we are making documentation for (usually the current title) -- env.templateTitle - the template (or module, file, etc.) -- env.docTitle - the /doc subpage. -- env.sandboxTitle - the /sandbox subpage. -- env.testcasesTitle - the /testcases subpage. -- env.printTitle - the print version of the template, located at the /Print subpage. -- -- Data includes: -- env.protectionLevels - the protection levels table of the title object. -- env.subjectSpace - the number of the title's subject namespace. -- env.docSpace - the number of the namespace the title puts its documentation in. -- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace. -- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template. -- -- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value -- returned will be nil. --]] local env, envFuncs = {}, {} -- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value -- returned by that function is memoized in the env table so that we don't call any of the functions -- more than once. (Nils won't be memoized.) setmetatable(env, { __index = function (t, key) local envFunc = envFuncs[key] if envFunc then local success, val = pcall(envFunc) if success then env[key] = val -- Memoise the value. return val end end return nil end }) function envFuncs.title() -- The title object for the current page, or a test page passed with args.page. local title local titleArg = args.page if titleArg then title = mw.title.new(titleArg) else title = mw.title.getCurrentTitle() end return title end function envFuncs.templateTitle() --[[ -- The template (or module, etc.) title object. -- Messages: -- 'sandbox-subpage' --> 'sandbox' -- 'testcases-subpage' --> 'testcases' --]] local subjectSpace = env.subjectSpace local title = env.title local subpage = title.subpageText if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then return mw.title.makeTitle(subjectSpace, title.baseText) else return mw.title.makeTitle(subjectSpace, title.text) end end function envFuncs.docTitle() --[[ -- Title object of the /doc subpage. -- Messages: -- 'doc-subpage' --> 'doc' --]] local title = env.title local docname = args[1] -- User-specified doc page. local docpage if docname then docpage = docname else docpage = env.docpageBase .. '/' .. message('doc-subpage') end return mw.title.new(docpage) end function envFuncs.sandboxTitle() --[[ -- Title object for the /sandbox subpage. -- Messages: -- 'sandbox-subpage' --> 'sandbox' --]] return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage')) end function envFuncs.testcasesTitle() --[[ -- Title object for the /testcases subpage. -- Messages: -- 'testcases-subpage' --> 'testcases' --]] return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage')) end function envFuncs.printTitle() --[[ -- Title object for the /Print subpage. -- Messages: -- 'print-subpage' --> 'Print' --]] return env.templateTitle:subPageTitle(message('print-subpage')) end function envFuncs.protectionLevels() -- The protection levels table of the title object. return env.title.protectionLevels end function envFuncs.subjectSpace() -- The subject namespace number. return mw.site.namespaces[env.title.namespace].subject.id end function envFuncs.docSpace() -- The documentation namespace number. For most namespaces this is the same as the -- subject namespace. However, pages in the Article, File, MediaWiki or Category -- namespaces must have their /doc, /sandbox and /testcases pages in talk space. local subjectSpace = env.subjectSpace if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then return subjectSpace + 1 else return subjectSpace end end function envFuncs.docpageBase() -- The base page of the /doc, /sandbox, and /testcases subpages. -- For some namespaces this is the talk page, rather than the template page. local templateTitle = env.templateTitle local docSpace = env.docSpace local docSpaceText = mw.site.namespaces[docSpace].name -- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon. return docSpaceText .. ':' .. templateTitle.text end function envFuncs.compareUrl() -- Diff link between the sandbox and the main template using [[Special:ComparePages]]. local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle if templateTitle.exists and sandboxTitle.exists then local compareUrl = mw.uri.fullUrl( 'Special:ComparePages', {page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} ) return tostring(compareUrl) else return nil end end return env end ---------------------------------------------------------------------------- -- Auxiliary templates ---------------------------------------------------------------------------- p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext') function p._getModuleWikitext(args, env) local currentTitle = mw.title.getCurrentTitle() if currentTitle.contentModel ~= 'Scribunto' then return end pcall(require, currentTitle.prefixedText) -- if it fails, we don't care local moduleWikitext = package.loaded["Module:Module wikitext"] if moduleWikitext then return moduleWikitext.main() end end function p.sandboxNotice(args, env) --[=[ -- Generates a sandbox notice for display above sandbox pages. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-notice-image' --> '[[Image:Sandbox.svg|50px|alt=|link=]]' -- 'sandbox-notice-blurb' --> 'This is the $1 for $2.' -- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).' -- 'sandbox-notice-pagetype-template' --> '[[w:Wikipedia:Template test cases|template sandbox]] page' -- 'sandbox-notice-pagetype-module' --> '[[w:Wikipedia:Template test cases|module sandbox]] page' -- 'sandbox-notice-pagetype-other' --> 'sandbox page' -- 'sandbox-notice-compare-link-display' --> 'diff' -- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.' -- 'sandbox-notice-testcases-link-display' --> 'test cases' -- 'sandbox-category' --> 'Template sandboxes' --]=] local title = env.title local sandboxTitle = env.sandboxTitle local templateTitle = env.templateTitle local subjectSpace = env.subjectSpace if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then return nil end -- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text". local omargs = {} omargs.image = message('sandbox-notice-image') -- Get the text. We start with the opening blurb, which is something like -- "This is the template sandbox for [[Template:Foo]] (diff)." local text = '' local frame = mw.getCurrentFrame() local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed. local pagetype if subjectSpace == 10 then pagetype = message('sandbox-notice-pagetype-template') elseif subjectSpace == 828 then pagetype = message('sandbox-notice-pagetype-module') else pagetype = message('sandbox-notice-pagetype-other') end local templateLink = makeWikilink(templateTitle.prefixedText) local compareUrl = env.compareUrl if isPreviewing or not compareUrl then text = text .. message('sandbox-notice-blurb', {pagetype, templateLink}) else local compareDisplay = message('sandbox-notice-compare-link-display') local compareLink = makeUrlLink(compareUrl, compareDisplay) text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink}) end -- Get the test cases page blurb if the page exists. This is something like -- "See also the companion subpage for [[Template:Foo/testcases|test cases]]." local testcasesTitle = env.testcasesTitle if testcasesTitle and testcasesTitle.exists then if testcasesTitle.contentModel == "Scribunto" then local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink}) else local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink}) end end -- Add the sandbox to the sandbox category. text = text .. makeCategoryLink(message('sandbox-category')) omargs.text = text omargs.class = message('sandbox-class') local ret = '<div style="clear: both;"></div>' ret = ret .. messageBox.main('ombox', omargs) return ret end function p.protectionTemplate(env) -- Generates the padlock icon in the top right. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'protection-template' --> 'pp-template' -- 'protection-template-args' --> {docusage = 'yes'} local title = env.title local protectionLevels local protectionTemplate = message('protection-template') local namespace = title.namespace if not (protectionTemplate and (namespace == 10 or namespace == 828)) then -- Don't display the protection template if we are not in the template or module namespaces. return nil end protectionLevels = env.protectionLevels if not protectionLevels then return nil end local editLevels = protectionLevels.edit local moveLevels = protectionLevels.move if moveLevels and moveLevels[1] == 'sysop' or editLevels and editLevels[1] then -- The page is full-move protected, or full, template, or semi-protected. local frame = mw.getCurrentFrame() return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')} else return nil end end ---------------------------------------------------------------------------- -- Start box ---------------------------------------------------------------------------- p.startBox = makeInvokeFunc('_startBox') function p._startBox(args, env) --[[ -- This function generates the start box. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make -- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox -- which generate the box HTML. --]] env = env or p.getEnvironment(args) local links local content = args.content if not content then -- No need to include the links if the documentation is on the template page itself. local linksData = p.makeStartBoxLinksData(args, env) if linksData then links = p.renderStartBoxLinks(linksData) end end -- Generate the start box html. local data = p.makeStartBoxData(args, env, links) if data then return p.renderStartBox(data) else -- User specified no heading. return nil end end function p.makeStartBoxLinksData(args, env) --[[ -- Does initial processing of data to make the [view] [edit] [history] [purge] links. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'view-link-display' --> 'view' -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'purge-link-display' --> 'purge' -- 'file-docpage-preload' --> 'Template:Documentation/preload-filespace' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'docpage-preload' --> 'Template:Documentation/preload' -- 'create-link-display' --> 'create' --]] local subjectSpace = env.subjectSpace local title = env.title local docTitle = env.docTitle if not title or not docTitle then return nil end if docTitle.isRedirect then docTitle = docTitle.redirectTarget end local data = {} data.title = title data.docTitle = docTitle -- View, display, edit, and purge links if /doc exists. data.viewLinkDisplay = i18n['view-link-display'] data.editLinkDisplay = i18n['edit-link-display'] data.historyLinkDisplay = i18n['history-link-display'] data.purgeLinkDisplay = i18n['purge-link-display'] -- Create link if /doc doesn't exist. local preload = args.preload if not preload then if subjectSpace == 6 then -- File namespace preload = message('file-docpage-preload') elseif subjectSpace == 828 then -- Module namespace preload = message('module-preload') else preload = message('docpage-preload') end end data.preload = preload data.createLinkDisplay = i18n['create-link-display'] return data end function p.renderStartBoxLinks(data) --[[ -- Generates the [view][edit][history][purge] or [create] links from the data table. -- @data - a table of data generated by p.makeStartBoxLinksData --]] local function escapeBrackets(s) -- Escapes square brackets with HTML entities. s = s:gsub('%[', '&#91;') -- Replace square brackets with HTML entities. s = s:gsub('%]', '&#93;') return s end local ret local docTitle = data.docTitle local title = data.title if docTitle.exists then local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay) local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay) local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay) local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay) ret = '[%s] [%s] [%s] [%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink) else local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay) ret = '[%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, createLink) end return ret end function p.makeStartBoxData(args, env, links) --[=[ -- Does initial processing of data to pass to the start-box render function, p.renderStartBox. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error. -- -- Messages: -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]' -- 'template-namespace-heading' --> 'Template documentation' -- 'module-namespace-heading' --> 'Module documentation' -- 'file-namespace-heading' --> 'Summary' -- 'other-namespaces-heading' --> 'Documentation' -- 'start-box-linkclasses' --> 'mw-editsection-like plainlinks' -- 'start-box-link-id' --> 'doc_editlinks' -- 'testcases-create-link-display' --> 'create' --]=] local subjectSpace = env.subjectSpace if not subjectSpace then -- Default to an "other namespaces" namespace, so that we get at least some output -- if an error occurs. subjectSpace = 2 end local data = {} -- Heading local heading = args.heading -- Blank values are not removed. if heading == '' then -- Don't display the start box if the heading arg is defined but blank. return nil end if heading then data.heading = heading elseif subjectSpace == 10 then -- Template namespace data.heading = i18n['template-namespace-heading'] elseif subjectSpace == 828 then -- Module namespace data.heading = i18n['module-namespace-heading'] elseif subjectSpace == 6 then -- File namespace data.heading = i18n['file-namespace-heading'] else data.heading = i18n['other-namespaces-heading'] end -- Data for the [view][edit][history][purge] or [create] links. if links then data.linksClass = message('start-box-linkclasses') data.linksId = message('start-box-link-id') data.links = links end return data end function p.renderStartBox(data) -- Renders the start box html. -- @data - a table of data generated by p.makeStartBoxData. local sbox = mw.html.create('div') sbox :addClass(message('header-div-class')) :tag('div') :addClass(message('heading-div-class')) :wikitext(data.heading) local links = data.links if links then sbox :tag('div') :addClass(data.linksClass) :attr('id', data.linksId) :wikitext(links) end return tostring(sbox) end ---------------------------------------------------------------------------- -- Documentation content ---------------------------------------------------------------------------- p.content = makeInvokeFunc('_content') function p._content(args, env) -- Displays the documentation contents -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment env = env or p.getEnvironment(args) local docTitle = env.docTitle local content = args.content if not content and docTitle and docTitle.exists then content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle} end -- The line breaks below are necessary so that "=== Headings ===" at the start and end -- of docs are interpreted correctly. local cbox = mw.html.create('div') cbox :addClass(message('content-div-class')) :wikitext('\n' .. (content or '') .. '\n') return tostring(cbox) end p.contentTitle = makeInvokeFunc('_contentTitle') function p._contentTitle(args, env) env = env or p.getEnvironment(args) local docTitle = env.docTitle if not args.content and docTitle and docTitle.exists then return docTitle.prefixedText else return '' end end ---------------------------------------------------------------------------- -- End box ---------------------------------------------------------------------------- p.endBox = makeInvokeFunc('_endBox') function p._endBox(args, env) --[=[ -- This function generates the end box (also known as the link box). -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment --]=] -- Get environment data. env = env or p.getEnvironment(args) local subjectSpace = env.subjectSpace local docTitle = env.docTitle if not subjectSpace or not docTitle then return nil end -- Check whether we should output the end box at all. Add the end -- box by default if the documentation exists or if we are in the -- user, module or template namespaces. local linkBox = args['link box'] if linkBox == 'off' or not ( docTitle.exists or subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 ) then return nil end -- Assemble the footer text field. local text = '' if linkBox then text = text .. linkBox else text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]." if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then -- We are in the user, template or module namespaces. -- Add sandbox and testcases links. -- "Editors can experiment in this template's sandbox and testcases pages." text = text .. (p.makeExperimentBlurb(args, env) or '') text = text .. '<br />' if not args.content and not args[1] then -- "Please add categories to the /doc subpage." -- Don't show this message with inline docs or with an explicitly specified doc page, -- as then it is unclear where to add the categories. text = text .. (p.makeCategoriesBlurb(args, env) or '') end text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template" local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates. if printBlurb then text = text .. '<br />' .. printBlurb end end end local ebox = mw.html.create('div') ebox :addClass(message('footer-div-class')) :wikitext(text) return tostring(ebox) end function p.makeDocPageBlurb(args, env) --[=[ -- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)". -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'transcluded-from-blurb' --> -- 'The above [[w:Wikipedia:Template documentation|documentation]] -- is [[w:Wikipedia:Transclusion|transcluded]] from $1.' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'create-link-display' --> 'create' -- 'create-module-doc-blurb' --> -- 'You might want to $1 a documentation page for this [[w:Wikipedia:Lua|Scribunto module]].' --]=] local docTitle = env.docTitle if not docTitle or args.content then return nil end local ret if docTitle.exists then -- /doc exists; link to it. local docLink = makeWikilink(docTitle.prefixedText) local editUrl = docTitle:fullUrl{action = 'edit'} local editDisplay = i18n['edit-link-display'] local editLink = makeUrlLink(editUrl, editDisplay) local historyUrl = docTitle:fullUrl{action = 'history'} local historyDisplay = i18n['history-link-display'] local historyLink = makeUrlLink(historyUrl, historyDisplay) ret = message('transcluded-from-blurb', {docLink}) .. ' ' .. makeToolbar(editLink, historyLink) .. '<br />' elseif env.subjectSpace == 828 then -- /doc does not exist; ask to create it. local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')} local createDisplay = i18n['create-link-display'] local createLink = makeUrlLink(createUrl, createDisplay) ret = message('create-module-doc-blurb', {createLink}) .. '<br />' end return ret end function p.makeExperimentBlurb(args, env) --[[ -- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-link-display' --> 'sandbox' -- 'sandbox-edit-link-display' --> 'edit' -- 'compare-link-display' --> 'diff' -- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'sandbox-create-link-display' --> 'create' -- 'mirror-edit-summary' --> 'Create sandbox version of $1' -- 'mirror-link-display' --> 'mirror' -- 'mirror-link-preload' --> 'Template:Documentation/mirror' -- 'sandbox-link-display' --> 'sandbox' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display'--> 'edit' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'testcases-create-link-display' --> 'create' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display' --> 'edit' -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases' -- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases' -- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.' -- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle local testcasesTitle = env.testcasesTitle local templatePage = templateTitle.prefixedText if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then return nil end -- Make links. local sandboxLinks, testcasesLinks if sandboxTitle.exists then local sandboxPage = sandboxTitle.prefixedText local sandboxDisplay = message('sandbox-link-display') local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'} local sandboxEditDisplay = message('sandbox-edit-link-display') local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay) local compareUrl = env.compareUrl local compareLink if compareUrl then local compareDisplay = message('compare-link-display') compareLink = makeUrlLink(compareUrl, compareDisplay) end sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) else local sandboxPreload if subjectSpace == 828 then sandboxPreload = message('module-sandbox-preload') else sandboxPreload = message('template-sandbox-preload') end local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload} local sandboxCreateDisplay = message('sandbox-create-link-display') local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) local mirrorPreload = message('mirror-link-preload') local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} local mirrorDisplay = message('mirror-link-display') local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) end if testcasesTitle.exists then local testcasesPage = testcasesTitle.prefixedText local testcasesDisplay = message('testcases-link-display') local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'} local testcasesEditDisplay = message('testcases-edit-link-display') local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) else local testcasesPreload if subjectSpace == 828 then testcasesPreload = message('module-testcases-preload') else testcasesPreload = message('template-testcases-preload') end local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload} local testcasesCreateDisplay = message('testcases-create-link-display') local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink) end local messageName if subjectSpace == 828 then messageName = 'experiment-blurb-module' else messageName = 'experiment-blurb-template' end return message(messageName, {sandboxLinks, testcasesLinks}) end function p.makeCategoriesBlurb(args, env) --[[ -- Generates the text "Please add categories to the /doc subpage." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'doc-link-display' --> '/doc' -- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.' --]] local docTitle = env.docTitle if not docTitle then return nil end local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display')) return message('add-categories-blurb', {docPathLink}) end function p.makeSubpagesBlurb(args, env) --[[ -- Generates the "Subpages of this template" link. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'template-pagetype' --> 'template' -- 'module-pagetype' --> 'module' -- 'default-pagetype' --> 'page' -- 'subpages-link-display' --> 'Subpages of this $1' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle if not subjectSpace or not templateTitle then return nil end local pagetype if subjectSpace == 10 then pagetype = message('template-pagetype') elseif subjectSpace == 828 then pagetype = message('module-pagetype') else pagetype = message('default-pagetype') end local subpagesLink = makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpages-link-display', {pagetype}) ) return message('subpages-blurb', {subpagesLink}) end function p.makePrintBlurb(args, env) --[=[ -- Generates the blurb displayed when there is a print version of the template available. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'print-link-display' --> '/Print' -- 'print-blurb' --> 'A [[Help:Books/for experts#Improving the book layout|print version]]' -- .. ' of this template exists at $1.' -- .. ' If you make a change to this template, please update the print version as well.' -- 'display-print-category' --> true -- 'print-category' --> 'Templates with print versions' --]=] local printTitle = env.printTitle if not printTitle then return nil end local ret if printTitle.exists then local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display')) ret = message('print-blurb', {printLink}) local displayPrintCategory = message('display-print-category', nil, 'boolean') if displayPrintCategory then ret = ret .. makeCategoryLink(message('print-category')) end end return ret end ---------------------------------------------------------------------------- -- Tracking categories ---------------------------------------------------------------------------- function p.addTrackingCategories(env) --[[ -- Check if {{documentation}} is transcluded on a /doc or /testcases page. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'display-strange-usage-category' --> true -- 'doc-subpage' --> 'doc' -- 'testcases-subpage' --> 'testcases' -- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage' -- -- /testcases pages in the module namespace are not categorised, as they may have -- {{documentation}} transcluded automatically. --]] local title = env.title local subjectSpace = env.subjectSpace if not title or not subjectSpace then return nil end local subpage = title.subpageText local ret = '' if message('display-strange-usage-category', nil, 'boolean') and ( subpage == message('doc-subpage') or subjectSpace ~= 828 and subpage == message('testcases-subpage') ) then ret = ret .. makeCategoryLink(message('strange-usage-category')) end return ret end return p 0e23eec0d3c20c23afcd28849e240b9083dbcf88 Module:Arguments 828 9 22 2024-04-03T03:01:09Z Nulcow 2 Created page with "-- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke directly. local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType local arguments = {} -- Generate four different tidyVal functions, so that we don't have to check the -- options every time we call it. local function tidyValDefault(key, val) if type(val) == 'string'..." Scribunto text/plain -- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke directly. local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType local arguments = {} -- Generate four different tidyVal functions, so that we don't have to check the -- options every time we call it. local function tidyValDefault(key, val) if type(val) == 'string' then val = val:match('^%s*(.-)%s*$') if val == '' then return nil else return val end else return val end end local function tidyValTrimOnly(key, val) if type(val) == 'string' then return val:match('^%s*(.-)%s*$') else return val end end local function tidyValRemoveBlanksOnly(key, val) if type(val) == 'string' then if val:find('%S') then return val else return nil end else return val end end local function tidyValNoChange(key, val) return val end local function matchesTitle(given, title) local tp = type( given ) return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title end local translate_mt = { __index = function(t, k) return k end } function arguments.getArgs(frame, options) checkType('getArgs', 1, frame, 'table', true) checkType('getArgs', 2, options, 'table', true) frame = frame or {} options = options or {} --[[ -- Set up argument translation. --]] options.translate = options.translate or {} if getmetatable(options.translate) == nil then setmetatable(options.translate, translate_mt) end if options.backtranslate == nil then options.backtranslate = {} for k,v in pairs(options.translate) do options.backtranslate[v] = k end end if options.backtranslate and getmetatable(options.backtranslate) == nil then setmetatable(options.backtranslate, { __index = function(t, k) if options.translate[k] ~= k then return nil else return k end end }) end --[[ -- Get the argument tables. If we were passed a valid frame object, get the -- frame arguments (fargs) and the parent frame arguments (pargs), depending -- on the options set and on the parent frame's availability. If we weren't -- passed a valid frame object, we are being called from another Lua module -- or from the debug console, so assume that we were passed a table of args -- directly, and assign it to a new variable (luaArgs). --]] local fargs, pargs, luaArgs if type(frame.args) == 'table' and type(frame.getParent) == 'function' then if options.wrappers then --[[ -- The wrappers option makes Module:Arguments look up arguments in -- either the frame argument table or the parent argument table, but -- not both. This means that users can use either the #invoke syntax -- or a wrapper template without the loss of performance associated -- with looking arguments up in both the frame and the parent frame. -- Module:Arguments will look up arguments in the parent frame -- if it finds the parent frame's title in options.wrapper; -- otherwise it will look up arguments in the frame object passed -- to getArgs. --]] local parent = frame:getParent() if not parent then fargs = frame.args else local title = parent:getTitle():gsub('/sandbox$', '') local found = false if matchesTitle(options.wrappers, title) then found = true elseif type(options.wrappers) == 'table' then for _,v in pairs(options.wrappers) do if matchesTitle(v, title) then found = true break end end end -- We test for false specifically here so that nil (the default) acts like true. if found or options.frameOnly == false then pargs = parent.args end if not found or options.parentOnly == false then fargs = frame.args end end else -- options.wrapper isn't set, so check the other options. if not options.parentOnly then fargs = frame.args end if not options.frameOnly then local parent = frame:getParent() pargs = parent and parent.args or nil end end if options.parentFirst then fargs, pargs = pargs, fargs end else luaArgs = frame end -- Set the order of precedence of the argument tables. If the variables are -- nil, nothing will be added to the table, which is how we avoid clashes -- between the frame/parent args and the Lua args. local argTables = {fargs} argTables[#argTables + 1] = pargs argTables[#argTables + 1] = luaArgs --[[ -- Generate the tidyVal function. If it has been specified by the user, we -- use that; if not, we choose one of four functions depending on the -- options chosen. This is so that we don't have to call the options table -- every time the function is called. --]] local tidyVal = options.valueFunc if tidyVal then if type(tidyVal) ~= 'function' then error( "bad value assigned to option 'valueFunc'" .. '(function expected, got ' .. type(tidyVal) .. ')', 2 ) end elseif options.trim ~= false then if options.removeBlanks ~= false then tidyVal = tidyValDefault else tidyVal = tidyValTrimOnly end else if options.removeBlanks ~= false then tidyVal = tidyValRemoveBlanksOnly else tidyVal = tidyValNoChange end end --[[ -- Set up the args, metaArgs and nilArgs tables. args will be the one -- accessed from functions, and metaArgs will hold the actual arguments. Nil -- arguments are memoized in nilArgs, and the metatable connects all of them -- together. --]] local args, metaArgs, nilArgs, metatable = {}, {}, {}, {} setmetatable(args, metatable) local function mergeArgs(tables) --[[ -- Accepts multiple tables as input and merges their keys and values -- into one table. If a value is already present it is not overwritten; -- tables listed earlier have precedence. We are also memoizing nil -- values, which can be overwritten if they are 's' (soft). --]] for _, t in ipairs(tables) do for key, val in pairs(t) do if metaArgs[key] == nil and nilArgs[key] ~= 'h' then local tidiedVal = tidyVal(key, val) if tidiedVal == nil then nilArgs[key] = 's' else metaArgs[key] = tidiedVal end end end end end --[[ -- Define metatable behaviour. Arguments are memoized in the metaArgs table, -- and are only fetched from the argument tables once. Fetching arguments -- from the argument tables is the most resource-intensive step in this -- module, so we try and avoid it where possible. For this reason, nil -- arguments are also memoized, in the nilArgs table. Also, we keep a record -- in the metatable of when pairs and ipairs have been called, so we do not -- run pairs and ipairs on the argument tables more than once. We also do -- not run ipairs on fargs and pargs if pairs has already been run, as all -- the arguments will already have been copied over. --]] metatable.__index = function (t, key) --[[ -- Fetches an argument when the args table is indexed. First we check -- to see if the value is memoized, and if not we try and fetch it from -- the argument tables. When we check memoization, we need to check -- metaArgs before nilArgs, as both can be non-nil at the same time. -- If the argument is not present in metaArgs, we also check whether -- pairs has been run yet. If pairs has already been run, we return nil. -- This is because all the arguments will have already been copied into -- metaArgs by the mergeArgs function, meaning that any other arguments -- must be nil. --]] if type(key) == 'string' then key = options.translate[key] end local val = metaArgs[key] if val ~= nil then return val elseif metatable.donePairs or nilArgs[key] then return nil end for _, argTable in ipairs(argTables) do local argTableVal = tidyVal(key, argTable[key]) if argTableVal ~= nil then metaArgs[key] = argTableVal return argTableVal end end nilArgs[key] = 'h' return nil end metatable.__newindex = function (t, key, val) -- This function is called when a module tries to add a new value to the -- args table, or tries to change an existing value. if type(key) == 'string' then key = options.translate[key] end if options.readOnly then error( 'could not write to argument table key "' .. tostring(key) .. '"; the table is read-only', 2 ) elseif options.noOverwrite and args[key] ~= nil then error( 'could not write to argument table key "' .. tostring(key) .. '"; overwriting existing arguments is not permitted', 2 ) elseif val == nil then --[[ -- If the argument is to be overwritten with nil, we need to erase -- the value in metaArgs, so that __index, __pairs and __ipairs do -- not use a previous existing value, if present; and we also need -- to memoize the nil in nilArgs, so that the value isn't looked -- up in the argument tables if it is accessed again. --]] metaArgs[key] = nil nilArgs[key] = 'h' else metaArgs[key] = val end end local function translatenext(invariant) local k, v = next(invariant.t, invariant.k) invariant.k = k if k == nil then return nil elseif type(k) ~= 'string' or not options.backtranslate then return k, v else local backtranslate = options.backtranslate[k] if backtranslate == nil then -- Skip this one. This is a tail call, so this won't cause stack overflow return translatenext(invariant) else return backtranslate, v end end end metatable.__pairs = function () -- Called when pairs is run on the args table. if not metatable.donePairs then mergeArgs(argTables) metatable.donePairs = true end return translatenext, { t = metaArgs } end local function inext(t, i) -- This uses our __index metamethod local v = t[i + 1] if v ~= nil then return i + 1, v end end metatable.__ipairs = function (t) -- Called when ipairs is run on the args table. return inext, t, 0 end return args end return arguments 3134ecce8429b810d445e29eae115e2ae4c36c53 Module:Message box 828 10 23 2024-04-03T03:01:58Z Nulcow 2 Created page with "-- This is a meta-module for producing message box templates, including -- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}. -- Load necessary modules. require('strict') local getArgs local yesno = require('Module:Yesno') -- Get a language object for formatDate and ucfirst. local lang = mw.language.getContentLanguage() -- Define constants local CONFIG_MODULE = 'Module:Message box/configuration' local DEMOSPACES = {talk = 'tmbox', image = '..." Scribunto text/plain -- This is a meta-module for producing message box templates, including -- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}. -- Load necessary modules. require('strict') local getArgs local yesno = require('Module:Yesno') -- Get a language object for formatDate and ucfirst. local lang = mw.language.getContentLanguage() -- Define constants local CONFIG_MODULE = 'Module:Message box/configuration' local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} local TEMPLATE_STYLES = 'Module:Message box/%s.css' -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function getTitleObject(...) -- Get the title object, passing the function through pcall -- in case we are over the expensive function count limit. local success, title = pcall(mw.title.new, ...) if success then return title end end local function union(t1, t2) -- Returns the union of two arrays. local vals = {} for i, v in ipairs(t1) do vals[v] = true end for i, v in ipairs(t2) do vals[v] = true end local ret = {} for k in pairs(vals) do table.insert(ret, k) end table.sort(ret) return ret end local function getArgNums(args, prefix) local nums = {} for k, v in pairs(args) do local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end -------------------------------------------------------------------------------- -- Box class definition -------------------------------------------------------------------------------- local MessageBox = {} MessageBox.__index = MessageBox function MessageBox.new(boxType, args, cfg) args = args or {} local obj = {} obj.boxType = boxType -- Set the title object and the namespace. obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle() -- Set the config for our box type. obj.cfg = cfg[boxType] if not obj.cfg then local ns = obj.title.namespace -- boxType is "mbox" or invalid input if args.demospace and args.demospace ~= '' then -- implement demospace parameter of mbox local demospace = string.lower(args.demospace) if DEMOSPACES[demospace] then -- use template from DEMOSPACES obj.cfg = cfg[DEMOSPACES[demospace]] obj.boxType = DEMOSPACES[demospace] elseif string.find( demospace, 'talk' ) then -- demo as a talk page obj.cfg = cfg.tmbox obj.boxType = 'tmbox' else -- default to ombox obj.cfg = cfg.ombox obj.boxType = 'ombox' end elseif ns == 0 then obj.cfg = cfg.ambox -- main namespace obj.boxType = 'ambox' elseif ns == 6 then obj.cfg = cfg.imbox -- file namespace obj.boxType = 'imbox' elseif ns == 14 then obj.cfg = cfg.cmbox -- category namespace obj.boxType = 'cmbox' else local nsTable = mw.site.namespaces[ns] if nsTable and nsTable.isTalk then obj.cfg = cfg.tmbox -- any talk namespace obj.boxType = 'tmbox' else obj.cfg = cfg.ombox -- other namespaces or invalid input obj.boxType = 'ombox' end end end -- Set the arguments, and remove all blank arguments except for the ones -- listed in cfg.allowBlankParams. do local newArgs = {} for k, v in pairs(args) do if v ~= '' then newArgs[k] = v end end for i, param in ipairs(obj.cfg.allowBlankParams or {}) do newArgs[param] = args[param] end obj.args = newArgs end -- Define internal data structure. obj.categories = {} obj.classes = {} -- For lazy loading of [[Module:Category handler]]. obj.hasCategories = false return setmetatable(obj, MessageBox) end function MessageBox:addCat(ns, cat, sort) if not cat then return nil end if sort then cat = string.format('[[Category:%s|%s]]', cat, sort) else cat = string.format('[[Category:%s]]', cat) end self.hasCategories = true self.categories[ns] = self.categories[ns] or {} table.insert(self.categories[ns], cat) end function MessageBox:addClass(class) if not class then return nil end self.classes[class] = 1 end function MessageBox:removeClass(class) if not class then return nil end self.classes[class] = nil end function MessageBox:setParameters() local args = self.args local cfg = self.cfg -- Get type data. self.type = args.type local typeData = cfg.types[self.type] self.invalidTypeError = cfg.showInvalidTypeError and self.type and not typeData typeData = typeData or cfg.types[cfg.default] self.typeClass = typeData.class self.typeImage = typeData.image -- Find if the box has been wrongly substituted. self.isSubstituted = cfg.substCheck and args.subst == 'SUBST' -- Find whether we are using a small message box. self.isSmall = cfg.allowSmall and ( cfg.smallParam and args.small == cfg.smallParam or not cfg.smallParam and yesno(args.small) ) -- Add attributes, classes and styles. self.id = args.id self.name = args.name for _, class in ipairs(cfg.classes or {}) do self:addClass(class) end if self.name then self:addClass('box-' .. string.gsub(self.name,' ','_')) end local plainlinks = yesno(args.plainlinks) if plainlinks == true then self:addClass('plainlinks') elseif plainlinks == false then self:removeClass('plainlinks') end if self.isSmall then self:addClass(cfg.smallClass or 'mbox-small') end self:addClass(self.typeClass) self:addClass(args.class) self.style = args.style self.attrs = args.attrs -- Set text style. self.textstyle = args.textstyle -- Find if we are on the template page or not. This functionality is only -- used if useCollapsibleTextFields is set, or if both cfg.templateCategory -- and cfg.templateCategoryRequireName are set. self.useCollapsibleTextFields = cfg.useCollapsibleTextFields if self.useCollapsibleTextFields or cfg.templateCategory and cfg.templateCategoryRequireName then if self.name then local templateName = mw.ustring.match( self.name, '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' ) or self.name templateName = 'Template:' .. templateName self.templateTitle = getTitleObject(templateName) end self.isTemplatePage = self.templateTitle and mw.title.equals(self.title, self.templateTitle) end -- Process data for collapsible text fields. At the moment these are only -- used in {{ambox}}. if self.useCollapsibleTextFields then -- Get the self.issue value. if self.isSmall and args.smalltext then self.issue = args.smalltext else local sect if args.sect == '' then sect = 'This ' .. (cfg.sectionDefault or 'page') elseif type(args.sect) == 'string' then sect = 'This ' .. args.sect end local issue = args.issue issue = type(issue) == 'string' and issue ~= '' and issue or nil local text = args.text text = type(text) == 'string' and text or nil local issues = {} table.insert(issues, sect) table.insert(issues, issue) table.insert(issues, text) self.issue = table.concat(issues, ' ') end -- Get the self.talk value. local talk = args.talk -- Show talk links on the template page or template subpages if the talk -- parameter is blank. if talk == '' and self.templateTitle and ( mw.title.equals(self.templateTitle, self.title) or self.title:isSubpageOf(self.templateTitle) ) then talk = '#' elseif talk == '' then talk = nil end if talk then -- If the talk value is a talk page, make a link to that page. Else -- assume that it's a section heading, and make a link to the talk -- page of the current page with that section heading. local talkTitle = getTitleObject(talk) local talkArgIsTalkPage = true if not talkTitle or not talkTitle.isTalkPage then talkArgIsTalkPage = false talkTitle = getTitleObject( self.title.text, mw.site.namespaces[self.title.namespace].talk.id ) end if talkTitle and talkTitle.exists then local talkText = 'Relevant discussion may be found on' if talkArgIsTalkPage then talkText = string.format( '%s [[%s|%s]].', talkText, talk, talkTitle.prefixedText ) else talkText = string.format( '%s the [[%s#%s|talk page]].', talkText, talkTitle.prefixedText, talk ) end self.talk = talkText end end -- Get other values. self.fix = args.fix ~= '' and args.fix or nil local date if args.date and args.date ~= '' then date = args.date elseif args.date == '' and self.isTemplatePage then date = lang:formatDate('F Y') end if date then self.date = string.format(" <small class='date-container'>''(<span class='date'>%s</span>)''</small>", date) end self.info = args.info if yesno(args.removalnotice) then self.removalNotice = cfg.removalNotice end end -- Set the non-collapsible text field. At the moment this is used by all box -- types other than ambox, and also by ambox when small=yes. if self.isSmall then self.text = args.smalltext or args.text else self.text = args.text end -- Set the below row. self.below = cfg.below and args.below -- General image settings. self.imageCellDiv = not self.isSmall and cfg.imageCellDiv self.imageEmptyCell = cfg.imageEmptyCell if cfg.imageEmptyCellStyle then self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px' end -- Left image settings. local imageLeft = self.isSmall and args.smallimage or args.image if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none' or not cfg.imageCheckBlank and imageLeft ~= 'none' then self.imageLeft = imageLeft if not imageLeft then local imageSize = self.isSmall and (cfg.imageSmallSize or '30x30px') or '40x40px' self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage or 'Information icon4.svg', imageSize) end end -- Right image settings. local imageRight = self.isSmall and args.smallimageright or args.imageright if not (cfg.imageRightNone and imageRight == 'none') then self.imageRight = imageRight end end function MessageBox:setMainspaceCategories() local args = self.args local cfg = self.cfg if not cfg.allowMainspaceCategories then return nil end local nums = {} for _, prefix in ipairs{'cat', 'category', 'all'} do args[prefix .. '1'] = args[prefix] nums = union(nums, getArgNums(args, prefix)) end -- The following is roughly equivalent to the old {{Ambox/category}}. local date = args.date date = type(date) == 'string' and date local preposition = 'from' for _, num in ipairs(nums) do local mainCat = args['cat' .. tostring(num)] or args['category' .. tostring(num)] local allCat = args['all' .. tostring(num)] mainCat = type(mainCat) == 'string' and mainCat allCat = type(allCat) == 'string' and allCat if mainCat and date and date ~= '' then local catTitle = string.format('%s %s %s', mainCat, preposition, date) self:addCat(0, catTitle) catTitle = getTitleObject('Category:' .. catTitle) if not catTitle or not catTitle.exists then self:addCat(0, 'Articles with invalid date parameter in template') end elseif mainCat and (not date or date == '') then self:addCat(0, mainCat) end if allCat then self:addCat(0, allCat) end end end function MessageBox:setTemplateCategories() local args = self.args local cfg = self.cfg -- Add template categories. if cfg.templateCategory then if cfg.templateCategoryRequireName then if self.isTemplatePage then self:addCat(10, cfg.templateCategory) end elseif not self.title.isSubpage then self:addCat(10, cfg.templateCategory) end end -- Add template error categories. if cfg.templateErrorCategory then local templateErrorCategory = cfg.templateErrorCategory local templateCat, templateSort if not self.name and not self.title.isSubpage then templateCat = templateErrorCategory elseif self.isTemplatePage then local paramsToCheck = cfg.templateErrorParamsToCheck or {} local count = 0 for i, param in ipairs(paramsToCheck) do if not args[param] then count = count + 1 end end if count > 0 then templateCat = templateErrorCategory templateSort = tostring(count) end if self.categoryNums and #self.categoryNums > 0 then templateCat = templateErrorCategory templateSort = 'C' end end self:addCat(10, templateCat, templateSort) end end function MessageBox:setAllNamespaceCategories() -- Set categories for all namespaces. if self.isSubstituted then self:addCat('all', 'Pages with incorrectly substituted templates') end end function MessageBox:setCategories() if self.title.namespace == 0 then self:setMainspaceCategories() elseif self.title.namespace == 10 then self:setTemplateCategories() end self:setAllNamespaceCategories() end function MessageBox:renderCategories() if not self.hasCategories then -- No categories added, no need to pass them to Category handler so, -- if it was invoked, it would return the empty string. -- So we shortcut and return the empty string. return "" end -- Convert category tables to strings and pass them through -- [[Module:Category handler]]. return require('Module:Category handler')._main{ main = table.concat(self.categories[0] or {}), template = table.concat(self.categories[10] or {}), all = table.concat(self.categories.all or {}), nocat = self.args.nocat, page = self.args.page } end function MessageBox:export() local root = mw.html.create() -- Add the subst check error. if self.isSubstituted and self.name then root:tag('b') :addClass('error') :wikitext(string.format( 'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.', mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') )) end -- Add TemplateStyles root:wikitext(mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = TEMPLATE_STYLES:format(self.boxType) }, }) -- Create the box table. local boxTable -- Check for fmbox because not all interface messages have mw-parser-output -- which is necessary for TemplateStyles. Add the wrapper class if it is and -- then start the actual mbox, else start the mbox. if self.boxType == 'fmbox' then boxTable = root:tag('div') :addClass('mw-parser-output') :tag('table') else boxTable = root:tag('table') end boxTable:attr('id', self.id or nil) for class, _ in pairs(self.classes or {}) do boxTable:addClass(class or nil) end boxTable :cssText(self.style or nil) :attr('role', 'presentation') if self.attrs then boxTable:attr(self.attrs) end -- Add the left-hand image. local row = boxTable:tag('tr') if self.imageLeft then local imageLeftCell = row:tag('td'):addClass('mbox-image') if self.imageCellDiv then -- If we are using a div, redefine imageLeftCell so that the image -- is inside it. Divs use style="width: 52px;", which limits the -- image width to 52px. If any images in a div are wider than that, -- they may overlap with the text or cause other display problems. imageLeftCell = imageLeftCell:tag('div'):css('width', '52px') end imageLeftCell:wikitext(self.imageLeft or nil) elseif self.imageEmptyCell then -- Some message boxes define an empty cell if no image is specified, and -- some don't. The old template code in templates where empty cells are -- specified gives the following hint: "No image. Cell with some width -- or padding necessary for text cell to have 100% width." row:tag('td') :addClass('mbox-empty-cell') :cssText(self.imageEmptyCellStyle or nil) end -- Add the text. local textCell = row:tag('td'):addClass('mbox-text') if self.useCollapsibleTextFields then -- The message box uses advanced text parameters that allow things to be -- collapsible. At the moment, only ambox uses this. textCell:cssText(self.textstyle or nil) local textCellDiv = textCell:tag('div') textCellDiv :addClass('mbox-text-span') :wikitext(self.issue or nil) if (self.talk or self.fix) and not self.isSmall then textCellDiv:tag('span') :addClass('hide-when-compact') :wikitext(self.talk and (' ' .. self.talk) or nil) :wikitext(self.fix and (' ' .. self.fix) or nil) end textCellDiv:wikitext(self.date and (' ' .. self.date) or nil) if self.info and not self.isSmall then textCellDiv :tag('span') :addClass('hide-when-compact') :wikitext(self.info and (' ' .. self.info) or nil) end if self.removalNotice then textCellDiv:tag('small') :addClass('hide-when-compact') :tag('i') :wikitext(string.format(" (%s)", self.removalNotice)) end else -- Default text formatting - anything goes. textCell :cssText(self.textstyle or nil) :wikitext(self.text or nil) end -- Add the right-hand image. if self.imageRight then local imageRightCell = row:tag('td'):addClass('mbox-imageright') if self.imageCellDiv then -- If we are using a div, redefine imageRightCell so that the image -- is inside it. imageRightCell = imageRightCell:tag('div'):css('width', '52px') end imageRightCell :wikitext(self.imageRight or nil) end -- Add the below row. if self.below then boxTable:tag('tr') :tag('td') :attr('colspan', self.imageRight and '3' or '2') :addClass('mbox-text') :cssText(self.textstyle or nil) :wikitext(self.below or nil) end -- Add error message for invalid type parameters. if self.invalidTypeError then root:tag('div') :css('text-align', 'center') :wikitext(string.format( 'This message box is using an invalid "type=%s" parameter and needs fixing.', self.type or '' )) end -- Add categories. root:wikitext(self:renderCategories() or nil) return tostring(root) end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p, mt = {}, {} function p._exportClasses() -- For testing. return { MessageBox = MessageBox } end function p.main(boxType, args, cfgTables) local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE)) box:setParameters() box:setCategories() return box:export() end function mt.__index(t, k) return function (frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) end end return setmetatable(p, mt) 05da6c4f204e9877c212b3df9fc8bad71389715a Module:Yesno 828 11 24 2024-04-03T03:02:38Z Nulcow 2 Created page with "-- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}. return function (val, default) -- If your wiki uses non-ascii characters for any of "yes", "no", etc., you -- should replace "val:lower()" with "mw.ustring.lower(val)" in the -- following line. val = type(val) == 'string' and val:lower() or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y' or val =..." Scribunto text/plain -- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}. return function (val, default) -- If your wiki uses non-ascii characters for any of "yes", "no", etc., you -- should replace "val:lower()" with "mw.ustring.lower(val)" in the -- following line. val = type(val) == 'string' and val:lower() or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y' or val == 'true' or val == 't' or val == 'on' or tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n' or val == 'false' or val == 'f' or val == 'off' or tonumber(val) == 0 then return false else return default end end f767643e7d12126d020d88d662a3dd057817b9dc Module:Documentation/config 828 12 25 2024-04-03T03:03:20Z Nulcow 2 Created page with "---------------------------------------------------------------------------------------------------- -- -- Configuration for Module:Documentation -- -- Here you can set the values of the parameters and messages used in Module:Documentation to -- localise it to your wiki and your language. Unless specified otherwise, values given here -- should be string values. ---------------------------------------------------------------------------------..." Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- -- Configuration for Module:Documentation -- -- Here you can set the values of the parameters and messages used in Module:Documentation to -- localise it to your wiki and your language. Unless specified otherwise, values given here -- should be string values. ---------------------------------------------------------------------------------------------------- local _format = require('Module:TNT').format local function format(id) return _format('I18n/Documentation', id) end local cfg = {} -- Do not edit this line. cfg['templatestyles-scr'] = 'Module:Documentation/styles.css' ---------------------------------------------------------------------------------------------------- -- Protection template configuration ---------------------------------------------------------------------------------------------------- -- cfg['protection-template'] -- The name of the template that displays the protection icon (a padlock on enwiki). cfg['protection-template'] = 'pp-template' -- cfg['protection-reason-edit'] -- The protection reason for edit-protected templates to pass to -- [[Module:Protection banner]]. cfg['protection-reason-edit'] = 'template' --[[ -- cfg['protection-template-args'] -- Any arguments to send to the protection template. This should be a Lua table. -- For example, if the protection template is "pp-template", and the wikitext template invocation -- looks like "{{pp-template|docusage=yes}}", then this table should look like "{docusage = 'yes'}". --]] cfg['protection-template-args'] = {docusage = 'yes'} --[[ ---------------------------------------------------------------------------------------------------- -- Sandbox notice configuration -- -- On sandbox pages the module can display a template notifying users that the current page is a -- sandbox, and the location of test cases pages, etc. The module decides whether the page is a -- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the -- messages that the notices contains. ---------------------------------------------------------------------------------------------------- --]] -- cfg['sandbox-notice-image'] -- The image displayed in the sandbox notice. cfg['sandbox-notice-image'] = '[[File:Edit In Sandbox Icon - Color.svg|40px|alt=|link=]]' --[[ -- cfg['sandbox-notice-pagetype-template'] -- cfg['sandbox-notice-pagetype-module'] -- cfg['sandbox-notice-pagetype-other'] -- The page type of the sandbox page. The message that is displayed depends on the current subject -- namespace. This message is used in either cfg['sandbox-notice-blurb'] or -- cfg['sandbox-notice-diff-blurb']. --]] cfg['sandbox-notice-pagetype-template'] = format('sandbox-notice-pagetype-template') cfg['sandbox-notice-pagetype-module'] = format('sandbox-notice-pagetype-module') cfg['sandbox-notice-pagetype-other'] = format('sandbox-notice-pagetype-other') --[[ -- cfg['sandbox-notice-blurb'] -- cfg['sandbox-notice-diff-blurb'] -- cfg['sandbox-notice-diff-display'] -- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence -- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page -- type, which is either cfg['sandbox-notice-pagetype-template'], -- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what -- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between -- the sandbox and the main template. The display value of the diff link is set by -- cfg['sandbox-notice-compare-link-display']. --]] cfg['sandbox-notice-blurb'] = format('sandbox-notice-blurb') cfg['sandbox-notice-diff-blurb'] = format('sandbox-notice-diff-blurb') cfg['sandbox-notice-compare-link-display'] = format('sandbox-notice-compare-link-display') --[[ -- cfg['sandbox-notice-testcases-blurb'] -- cfg['sandbox-notice-testcases-link-display'] -- cfg['sandbox-notice-testcases-run-blurb'] -- cfg['sandbox-notice-testcases-run-link-display'] -- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit. $1 is a link to the test cases page. -- cfg['sandbox-notice-testcases-link-display'] is the display value for that link. -- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test -- cases page, and $2 is a link to the page to run it. -- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test -- cases. --]] cfg['sandbox-notice-testcases-blurb'] = format('sandbox-notice-testcases-blurb') cfg['sandbox-notice-testcases-link-display'] = format('sandbox-notice-testcases-link-display') cfg['sandbox-notice-testcases-run-blurb'] = format('sandbox-notice-testcases-run-blurb') cfg['sandbox-notice-testcases-run-link-display'] = format('sandbox-notice-testcases-run-link-display') -- cfg['sandbox-category'] -- A category to add to all template sandboxes. cfg['sandbox-category'] = 'Template sandboxes' ---------------------------------------------------------------------------------------------------- -- Start box configuration ---------------------------------------------------------------------------------------------------- -- cfg['documentation-icon-wikitext'] -- The wikitext for the icon shown at the top of the template. cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]' ---------------------------------------------------------------------------------------------------- -- Link box (end box) configuration ---------------------------------------------------------------------------------------------------- -- cfg['transcluded-from-blurb'] -- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page. cfg['transcluded-from-blurb'] = format('transcluded-from-blurb') --[[ -- cfg['create-module-doc-blurb'] -- Notice displayed in the module namespace when the documentation subpage does not exist. -- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the -- display cfg['create-link-display']. --]] cfg['create-module-doc-blurb'] = format('create-module-doc-blurb') ---------------------------------------------------------------------------------------------------- -- Experiment blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['experiment-blurb-template'] -- cfg['experiment-blurb-module'] -- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages. -- It is only shown in the template and module namespaces. With the default English settings, it -- might look like this: -- -- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. -- -- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links. -- -- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending -- on what namespace we are in. -- -- Parameters: -- -- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display']) -- -- If the sandbox doesn't exist, it is in the format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display']) -- -- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload'] -- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display'] -- loads a default edit summary of cfg['mirror-edit-summary']. -- -- $2 is a link to the test cases page. If the test cases page exists, it is in the following format: -- -- cfg['testcases-link-display'] (cfg['testcases-edit-link-display']) -- -- If the test cases page doesn't exist, it is in the format: -- -- cfg['testcases-link-display'] (cfg['testcases-create-link-display']) -- -- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the -- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current -- namespace. --]] cfg['experiment-blurb-template'] = format('experiment-blurb-template') cfg['experiment-blurb-module'] = format('experiment-blurb-module') ---------------------------------------------------------------------------------------------------- -- Sandbox link configuration ---------------------------------------------------------------------------------------------------- -- cfg['sandbox-subpage'] -- The name of the template subpage typically used for sandboxes. cfg['sandbox-subpage'] = 'sandbox' -- cfg['template-sandbox-preload'] -- Preload file for template sandbox pages. cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox' -- cfg['module-sandbox-preload'] -- Preload file for Lua module sandbox pages. cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox' -- cfg['sandbox-link-display'] -- The text to display for "sandbox" links. cfg['sandbox-link-display'] = format('sandbox-link-display') -- cfg['sandbox-edit-link-display'] -- The text to display for sandbox "edit" links. cfg['sandbox-edit-link-display'] = format('sandbox-edit-link-display') -- cfg['sandbox-create-link-display'] -- The text to display for sandbox "create" links. cfg['sandbox-create-link-display'] = format('sandbox-create-link-display') -- cfg['compare-link-display'] -- The text to display for "compare" links. cfg['compare-link-display'] = format('compare-link-display') -- cfg['mirror-edit-summary'] -- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the -- template page. cfg['mirror-edit-summary'] = 'Create sandbox version of $1' -- cfg['mirror-link-display'] -- The text to display for "mirror" links. cfg['mirror-link-display'] = format('mirror-link-display') -- cfg['mirror-link-preload'] -- The page to preload when a user clicks the "mirror" link. cfg['mirror-link-preload'] = 'Template:Documentation/mirror' ---------------------------------------------------------------------------------------------------- -- Test cases link configuration ---------------------------------------------------------------------------------------------------- -- cfg['testcases-subpage'] -- The name of the template subpage typically used for test cases. cfg['testcases-subpage'] = 'testcases' -- cfg['template-testcases-preload'] -- Preload file for template test cases pages. cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases' -- cfg['module-testcases-preload'] -- Preload file for Lua module test cases pages. cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases' -- cfg['testcases-link-display'] -- The text to display for "testcases" links. cfg['testcases-link-display'] = format('testcases-link-display') -- cfg['testcases-edit-link-display'] -- The text to display for test cases "edit" links. cfg['testcases-edit-link-display'] = format('testcases-edit-link-display') -- cfg['testcases-create-link-display'] -- The text to display for test cases "create" links. cfg['testcases-create-link-display'] = format('testcases-create-link-display') ---------------------------------------------------------------------------------------------------- -- Add categories blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['add-categories-blurb'] -- Text to direct users to add categories to the /doc subpage. Not used if the "content" or -- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a -- link to the /doc subpage with a display value of cfg['doc-link-display']. --]] cfg['add-categories-blurb'] = format('add-categories-blurb') -- cfg['doc-link-display'] -- The text to display when linking to the /doc subpage. cfg['doc-link-display'] = '/doc' ---------------------------------------------------------------------------------------------------- -- Subpages link configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['subpages-blurb'] -- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a -- display value of cfg['subpages-link-display']. In the English version this blurb is simply -- the link followed by a period, and the link display provides the actual text. --]] cfg['subpages-blurb'] = format('subpages-blurb') --[[ -- cfg['subpages-link-display'] -- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'], -- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in -- the template namespace, the module namespace, or another namespace. --]] cfg['subpages-link-display'] = format('subpages-link-display') -- cfg['template-pagetype'] -- The pagetype to display for template pages. cfg['template-pagetype'] = format('template-pagetype') -- cfg['module-pagetype'] -- The pagetype to display for Lua module pages. cfg['module-pagetype'] = format('module-pagetype') -- cfg['default-pagetype'] -- The pagetype to display for pages other than templates or Lua modules. cfg['default-pagetype'] = format('default-pagetype') ---------------------------------------------------------------------------------------------------- -- Doc link configuration ---------------------------------------------------------------------------------------------------- -- cfg['doc-subpage'] -- The name of the subpage typically used for documentation pages. cfg['doc-subpage'] = 'doc' -- cfg['file-docpage-preload'] -- Preload file for documentation page in the file namespace. cfg['file-docpage-preload'] = 'Template:Documentation/preload-filespace' -- cfg['docpage-preload'] -- Preload file for template documentation pages in all namespaces. cfg['docpage-preload'] = 'Template:Documentation/preload' -- cfg['module-preload'] -- Preload file for Lua module documentation pages. cfg['module-preload'] = 'Template:Documentation/preload-module-doc' ---------------------------------------------------------------------------------------------------- -- Print version configuration ---------------------------------------------------------------------------------------------------- -- cfg['print-subpage'] -- The name of the template subpage used for print versions. cfg['print-subpage'] = 'Print' -- cfg['print-link-display'] -- The text to display when linking to the /Print subpage. cfg['print-link-display'] = '/Print' -- cfg['print-blurb'] -- Text to display if a /Print subpage exists. $1 is a link to the subpage with a display value of cfg['print-link-display']. cfg['print-blurb'] = format('print-blurb') -- cfg['display-print-category'] -- Set to true to enable output of cfg['print-category'] if a /Print subpage exists. -- This should be a boolean value (either true or false). cfg['display-print-category'] = true -- cfg['print-category'] -- Category to output if cfg['display-print-category'] is set to true, and a /Print subpage exists. cfg['print-category'] = 'Templates with print versions' ---------------------------------------------------------------------------------------------------- -- HTML and CSS configuration ---------------------------------------------------------------------------------------------------- -- cfg['main-div-id'] -- The "id" attribute of the main HTML "div" tag. cfg['main-div-id'] = 'template-documentation' -- cfg['main-div-classes'] -- The CSS classes added to the main HTML "div" tag. cfg['main-div-class'] = 'ts-doc-doc' cfg['header-div-class'] = 'ts-doc-header' cfg['heading-div-class'] = 'ts-doc-heading' cfg['content-div-class'] = 'ts-doc-content' cfg['footer-div-class'] = 'ts-doc-footer plainlinks' cfg['sandbox-class'] = 'ts-doc-sandbox' -- cfg['start-box-linkclasses'] -- The CSS classes used for the [view][edit][history] or [create] links in the start box. cfg['start-box-linkclasses'] = 'ts-tlinks-tlinks mw-editsection-like plainlinks' -- cfg['start-box-link-id'] -- The HTML "id" attribute for the links in the start box. cfg['start-box-link-id'] = 'doc_editlinks' ---------------------------------------------------------------------------------------------------- -- Tracking category configuration ---------------------------------------------------------------------------------------------------- -- cfg['display-strange-usage-category'] -- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage -- or a /testcases subpage. This should be a boolean value (either true or false). cfg['display-strange-usage-category'] = false -- cfg['strange-usage-category'] -- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a -- /doc subpage or a /testcases subpage. cfg['strange-usage-category'] = 'Pages with strange ((documentation)) usage' --[[ ---------------------------------------------------------------------------------------------------- -- End configuration -- -- Don't edit anything below this line. ---------------------------------------------------------------------------------------------------- --]] return cfg 2d847b9bb120cb550277fa38ab17484a7cd7ed58 Module:TNT 828 13 26 2024-04-03T03:03:56Z Nulcow 2 Created page with "-- -- INTRO: (!!! DO NOT RENAME THIS PAGE !!!) -- This module allows any template or module to be copy/pasted between -- wikis without any translation changes. All translation text is stored -- in the global Data:*.tab pages on Commons, and used everywhere. -- -- SEE: https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules -- -- ATTENTION: -- Please do NOT rename this module - it has to be identical on all wikis. -- This code is maintained..." Scribunto text/plain -- -- INTRO: (!!! DO NOT RENAME THIS PAGE !!!) -- This module allows any template or module to be copy/pasted between -- wikis without any translation changes. All translation text is stored -- in the global Data:*.tab pages on Commons, and used everywhere. -- -- SEE: https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules -- -- ATTENTION: -- Please do NOT rename this module - it has to be identical on all wikis. -- This code is maintained at https://www.mediawiki.org/wiki/Module:TNT -- Please do not modify it anywhere else, as it may get copied and override your changes. -- Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT -- -- DESCRIPTION: -- The "msg" function uses a Commons dataset to translate a message -- with a given key (e.g. source-table), plus optional arguments -- to the wiki markup in the current content language. -- Use lang=xx to set language. Example: -- -- {{#invoke:TNT | msg -- | I18n/Template:Graphs.tab <!-- https://commons.wikimedia.org/wiki/Data:I18n/Template:Graphs.tab --> -- | source-table <!-- uses a translation message with id = "source-table" --> -- | param1 }} <!-- optional parameter --> -- -- -- The "doc" function will generate the <templatedata> parameter documentation for templates. -- This way all template parameters can be stored and localized in a single Commons dataset. -- NOTE: "doc" assumes that all documentation is located in Data:Templatedata/* on Commons. -- -- {{#invoke:TNT | doc | Graph:Lines }} -- uses https://commons.wikimedia.org/wiki/Data:Templatedata/Graph:Lines.tab -- if the current page is Template:Graph:Lines/doc -- local p = {} local i18nDataset = 'I18n/Module:TNT.tab' -- Forward declaration of the local functions local sanitizeDataset, loadData, link, formatMessage function p.msg(frame) local dataset, id local params = {} local lang = nil for k, v in pairs(frame.args) do if k == 1 then dataset = mw.text.trim(v) elseif k == 2 then id = mw.text.trim(v) elseif type(k) == 'number' then params[k - 2] = mw.text.trim(v) elseif k == 'lang' and v ~= '_' then lang = mw.text.trim(v) end end return formatMessage(dataset, id, params, lang) end -- Identical to p.msg() above, but used from other lua modules -- Parameters: name of dataset, message key, optional arguments -- Example with 2 params: format('I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset') function p.format(dataset, key, ...) local checkType = require('libraryUtil').checkType checkType('format', 1, dataset, 'string') checkType('format', 2, key, 'string') return formatMessage(dataset, key, {...}) end -- Identical to p.msg() above, but used from other lua modules with the language param -- Parameters: language code, name of dataset, message key, optional arguments -- Example with 2 params: formatInLanguage('es', I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset') function p.formatInLanguage(lang, dataset, key, ...) local checkType = require('libraryUtil').checkType checkType('formatInLanguage', 1, lang, 'string') checkType('formatInLanguage', 2, dataset, 'string') checkType('formatInLanguage', 3, key, 'string') return formatMessage(dataset, key, {...}, lang) end -- Obsolete function that adds a 'c:' prefix to the first param. -- "Sandbox/Sample.tab" -> 'c:Data:Sandbox/Sample.tab' function p.link(frame) return link(frame.args[1]) end function p.doc(frame) local dataset = 'Templatedata/' .. sanitizeDataset(frame.args[1]) return frame:extensionTag('templatedata', p.getTemplateData(dataset)) .. formatMessage(i18nDataset, 'edit_doc', {link(dataset)}) end function p.getTemplateData(dataset) -- TODO: add '_' parameter once lua starts reindexing properly for "all" languages local data = loadData(dataset) local names = {} for _, field in ipairs(data.schema.fields) do table.insert(names, field.name) end local numOnly = true local params = {} local paramOrder = {} for _, row in ipairs(data.data) do local newVal = {} local name = nil for pos, columnName in ipairs(names) do if columnName == 'name' then name = row[pos] else newVal[columnName] = row[pos] end end if name then if ( (type(name) ~= "number") and ( (type(name) ~= "string") or not string.match(name, "^%d+$") ) ) then numOnly = false end params[name] = newVal table.insert(paramOrder, name) end end -- Work around json encoding treating {"1":{...}} as an [{...}] if numOnly then params['zzz123']='' end local json = mw.text.jsonEncode({ params=params, paramOrder=paramOrder, description=data.description, }) if numOnly then json = string.gsub(json,'"zzz123":"",?', "") end return json end -- Local functions sanitizeDataset = function(dataset) if not dataset then return nil end dataset = mw.text.trim(dataset) if dataset == '' then return nil elseif string.sub(dataset,-4) ~= '.tab' then return dataset .. '.tab' else return dataset end end loadData = function(dataset, lang) dataset = sanitizeDataset(dataset) if not dataset then error(formatMessage(i18nDataset, 'error_no_dataset', {})) end -- Give helpful error to thirdparties who try and copy this module. if not mw.ext or not mw.ext.data or not mw.ext.data.get then error(string.format([['''Missing JsonConfig extension, or not properly configured; Cannot load https://commons.wikimedia.org/wiki/Data:%s. See https://www.mediawiki.org/wiki/Extension:JsonConfig#Supporting_Wikimedia_templates''']], dataset)) end local data = mw.ext.data.get(dataset, lang) if data == false then if dataset == i18nDataset then -- Prevent cyclical calls error('Missing Commons dataset ' .. i18nDataset) else error(formatMessage(i18nDataset, 'error_bad_dataset', {link(dataset)})) end end return data end -- Given a dataset name, convert it to a title with the 'commons:data:' prefix link = function(dataset) return 'c:Data:' .. mw.text.trim(dataset or '') end formatMessage = function(dataset, key, params, lang) for _, row in pairs(loadData(dataset, lang).data) do local id, msg = unpack(row) if id == key then local result = mw.message.newRawMessage(msg, unpack(params or {})) return result:plain() end end if dataset == i18nDataset then -- Prevent cyclical calls error('Invalid message key "' .. key .. '"') else error(formatMessage(i18nDataset, 'error_bad_msgkey', {key, link(dataset)})) end end return p e8ec673cd9d57a37a2bc326979c7980f1657fc3a Template:Documentation 10 14 27 2024-04-03T03:05:33Z Nulcow 2 Created page with "<noinclude> <languages/> </noinclude><includeonly>{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}</includeonly><noinclude> {{documentation|content= {{Lua|Module:Documentation}} <translate><!--T:12--> This template automatically displays a documentation box like the one you are seeing now, of which the content is sometimes transcluded from another page.</translate> <translate><!--T:13--> It is intended for pages which are <tvar name=..." wikitext text/x-wiki <noinclude> <languages/> </noinclude><includeonly>{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}</includeonly><noinclude> {{documentation|content= {{Lua|Module:Documentation}} <translate><!--T:12--> This template automatically displays a documentation box like the one you are seeing now, of which the content is sometimes transcluded from another page.</translate> <translate><!--T:13--> It is intended for pages which are [[<tvar name=1>Special:MyLanguage/Help:Transclusion</tvar>|transcluded]] in other pages, i.e. templates, whether in the template namespace or not.</translate> <translate> ==Usage== <!--T:2--> ===Customising display=== <!--T:3--> <!--T:4--> Overrides exist to customise the output in special cases: </translate> * <nowiki>{{</nowiki>documentation{{!}}'''heading'''=<nowiki>}}</nowiki> - <translate><!--T:5--> change the text of the "documentation" heading.</translate> <translate><!--T:10--> If this is set to blank, the entire heading line (including the first [edit] link) will also disappear.</translate> <translate> ==Rationale== <!--T:6--> </translate> <translate><!--T:7--> This template allows any page to use any documentation page, and makes it possible to protect templates while allowing anyone to edit the template's documentation and categories.</translate> <translate><!--T:8--> It also reduces server resources by circumventing a [[w:Wikipedia:Template limits|technical limitation of templates]] (see a [[<tvar name=1>:en:Special:Diff/69888944</tvar>|developer's explanation]]).</translate> <translate> ==See also== <!--T:9--> </translate> * <translate><!--T:14--> [[w:Template:Documentation subpage]]</translate> * {{tim|Documentation}} * <translate><!--T:11--> [[w:Wikipedia:Template documentation]]</translate> }} [[Category:Formatting templates{{#translation:}}|Template documentation]] [[Category:Template documentation{{#translation:}}| ]] </noinclude><includeonly>{{#if:{{{content|}}}| [[Category:Template documentation pages{{#translation:}}]] }}</includeonly> c1ef6cbf9cb4c65ddd087c09aa6affb00dc5bfad Template:Excerpt 10 15 28 2024-04-03T03:11:20Z Nulcow 2 Created page with "<noinclude> <languages /> </noinclude><includeonly>{{#invoke:Excerpt|main}}</includeonly><noinclude> {{Documentation|content= {{Lua|Module:Excerpt}} <translate><!--T:111--> This template is used for reusing parts of pages in other pages.</translate> <translate><!--T:112--> This practice has several advantages:</translate> <translate> <!--T:113--> * '''Reduces maintenance''' by avoiding duplicate content that must be updated multiple times</translate> <translate> <!--T:..." wikitext text/x-wiki <noinclude> <languages /> </noinclude><includeonly>{{#invoke:Excerpt|main}}</includeonly><noinclude> {{Documentation|content= {{Lua|Module:Excerpt}} <translate><!--T:111--> This template is used for reusing parts of pages in other pages.</translate> <translate><!--T:112--> This practice has several advantages:</translate> <translate> <!--T:113--> * '''Reduces maintenance''' by avoiding duplicate content that must be updated multiple times</translate> <translate> <!--T:114--> * '''Improves content quality''' by encouraging editors to merge related content, rather than having multiple versions in various stages of development</translate> <translate> <!--T:115--> * '''Fosters collaboration''' by channeling contributors into one place, rather than working in parallel <!--T:116--> This template extends the capabilities of the built-in [[<tvar name=1>Special:MyLanguage/Transclusion</tvar>|normal transclusion]]. == Usage == <!--T:2--> === Basic usage === <!--T:3--> </translate> * <code><nowiki>{{Excerpt|Page title}}</nowiki></code> — <translate><!--T:4--> Transclude the lead section ([[<tvar name=1>#Lead section</tvar>|example]])</translate> * <code><nowiki>{{Excerpt|Page title|Section title}}</nowiki></code> — <translate><!--T:5--> Transclude a specific section, excluding any subsections ([[<tvar name=1>#Specific section</tvar>|example]])</translate> <translate> === Parameters === <!--T:6--> </translate> * <code>1</code> — <translate><!--T:7--> Title of the page to transclude.</translate> <translate><!--T:8--> '''Only required parameter.'''</translate> <translate><!--T:9--> By default the lead section will be transcluded ([[<tvar name=1>#Lead section</tvar>|example]]).</translate> * <code>2</code> — <translate><!--T:10--> Title of the section to transclude ([[<tvar name=1>#Specific section</tvar>|example]]) or name of the [[<tvar name=2>Special:MyLanguage/Extension:Labeled Section Transclusion#How it works</tvar>|<tvar name=3>{{tag|section|open}}</tvar> tag]] to transclude.</translate> <translate><!--T:119--> Notice that this template provides other ways of targeting specific elements of a page without having to resort to section tags.</translate> * <code>only</code> — <translate><!--T:11--> Elements to transclude ([[<tvar name=1>#Files only</tvar>|example]]).</translate> <translate><!--T:86--> By default all elements are transcluded.</translate> ** <code>only=file</code> <translate><!--T:106--> or</translate> <code>only=files</code> — <translate><!--T:12--> Transclude only files</translate> ** <code>only=list</code> <translate><!--T:107--> or</translate> <code>only=lists</code> — <translate><!--T:13--> Transclude only lists</translate> ** <code>only=table</code> <translate><!--T:108--> or</translate> <code>only=tables</code> — <translate><!--T:14--> Transclude only tables</translate> ** <code>only=template</code> <translate><!--T:109--> or</translate> <code>only=templates</code> — <translate><!--T:16--> Transclude only templates</translate> ** <code>only=paragraph</code> <translate><!--T:110--> or</translate> <code>only=paragraphs</code> — <translate><!--T:18--> Transclude only paragraphs</translate> * <code>paragraphs</code> — <translate><!--T:21--> Paragraphs to transclude.</translate> <translate><!--T:22--> By default all paragraphs are transcluded.</translate> ** <code>paragraphs=0</code> — <translate><!--T:24--> Transclude no paragraphs</translate> ** <code>paragraphs=1</code> — <translate><!--T:25--> Transclude the first paragraph</translate> ** <code>paragraphs=2</code> — <translate><!--T:26--> Transclude the second paragraph</translate> ** <code>paragraphs=1,3</code> — <translate><!--T:27--> Transclude the first and third paragraphs</translate> ** <code>paragraphs=1-3</code> — <translate><!--T:28--> Transclude the first, second and third paragraphs</translate> ** <code>paragraphs=1-3,5</code> — <translate><!--T:29--> Transclude the first, second, third and fifth paragraphs</translate> ** <code>paragraphs=-1</code> — <translate><!--T:30--> Transclude all paragraphs except the first</translate> ** <code>paragraphs=-2</code> — <translate><!--T:31--> Transclude all paragraphs except the second</translate> ** <code>paragraphs=-1,3</code> — <translate><!--T:32--> Transclude all paragraphs except the first and third</translate> ** <code>paragraphs=-1-3</code> — <translate><!--T:33--> Transclude all paragraphs except the first, second and third</translate> ** <code>paragraphs=-1-3,5</code> — <translate><!--T:34--> Transclude all paragraphs except the first, second, third and fifth</translate> * <code>lists</code> — <translate><!--T:87--> Lists to transclude.</translate> <translate><!--T:88--> By default all lists are transcluded.</translate> <translate><!--T:89--> Same syntax as when transcluding paragraphs.</translate> * <code>files</code> — <translate><!--T:35--> Files to transclude.</translate> <translate><!--T:36--> By default all files are transcluded.</translate> <translate><!--T:60--> Same syntax as when transcluding paragraphs, but also:</translate> ** <code>files=A.jpg</code> — <translate><!--T:38--> Transclude the file named '<tvar name=1>A.jpg</tvar>'</translate> ** <code>files=A.jpg, B.png, C.gif</code> — <translate><!--T:39--> Transclude the files named '<tvar name=1>A.jpg</tvar>', '<tvar name=2>B.png</tvar>' and '<tvar name=3>C.gif</tvar>'</translate> ** <code>files=.+%.png</code> — <translate><!--T:40--> Transclude all PNG files</translate> ** <code>files=-A.jpg</code> — <translate><!--T:41--> Transclude all files except the one named '<tvar name=1>A.jpg</tvar>'</translate> ** <code>files=-A.jpg, B.png, C.gif</code> — <translate><!--T:42--> Transclude all files except the ones named '<tvar name=1>A.jpg</tvar>', '<tvar name=2>B.png</tvar>' and '<tvar name=3>C.gif</tvar>'</translate> ** <code>files=-.+%.png</code> — <translate><!--T:43--> Transclude all non-PNG files</translate> * <code>tables</code> — <translate><!--T:44--> Tables to transclude.</translate> <translate><!--T:45--> By default all tables are transcluded.</translate> <translate><!--T:46--> Same syntax as when transcluding paragraphs, but also:</translate> ** <code>tables=Stats2020</code> — <translate><!--T:47--> Transclude the table with id '<tvar name=1>Stats2020</tvar>'</translate> ** <code>tables=Stats2020, Stats2019, Stats2018</code> — <translate><!--T:48--> Transclude the tables with ids '<tvar name=1>Stats2020</tvar>', '<tvar name=2>Stats2019</tvar>' and '<tvar name=3>Stats2018</tvar>'</translate> ** <code>tables=-Stats2020</code> — <translate><!--T:49--> Transclude all tables except the one with id '<tvar name=1>Stats2020</tvar>'</translate> ** <code>tables=-Stats2020, Stats2019, Stats2018</code> — <translate><!--T:50--> Transclude all tables except the ones with ids '<tvar name=1>Stats2020</tvar>', '<tvar name=2>Stats2019</tvar>' and '<tvar name=3>Stats2018</tvar>'</translate> * <code>templates</code> — <translate><!--T:90--> Templates to transclude.</translate> <translate><!--T:91--> By default all templates are transcluded.</translate> <translate><!--T:92--> Same syntax as when transcluding paragraphs, but also:</translate> ** <code>templates=Infobox</code> — <translate><!--T:93--> Transclude the template '<tvar name=1>Infobox</tvar>'</translate> ** <code>templates=Infobox, Navbox, Chart</code> — <translate><!--T:94--> Transclude the template '<tvar name=1>Infobox</tvar>', '<tvar name=2>Navbox</tvar>' and '<tvar name=3>Chart</tvar>'</translate> ** <code>templates=-Infobox</code> — <translate><!--T:95--> Transclude all templates except '<tvar name=1>Infobox</tvar>'</translate> ** <code>templates=-Infobox, Navbox, Chart</code> — <translate><!--T:96--> Transclude all templates except '<tvar name=1>Infobox</tvar>', '<tvar name=2>Navbox</tvar>' and '<tvar name=3>Chart</tvar>'</translate> * <code>this</code> — <translate><!--T:100--> Change the initial text of the hatnote. For example, if the transcluded content is a gallery, you can set <tvar name=1><code>this=This gallery is</code></tvar> so that the hatnote reads "This gallery is an excerpt from..."</translate> * <code>displaytitle</code> — <translate><!--T:121--> Change the text of the link in the hatnote. For example to add italics, subscripts, etc.</translate> * <code>hat=no</code> — <translate><!--T:101--> Hide the hatnote "This section is an excerpt from..."</translate> * <code>more=yes</code> — <translate><!--T:120--> Show a "Read more..." link at the end</translate> * <code>bold=yes</code> — <translate><!--T:117--> Keep bold text.</translate> * <code>quote=yes</code> — <translate><!--T:102--> Wrap the excerpt with <tvar name=1>{{tag|blockquote|open}}</tvar> tags.</translate> * <code>inline=yes</code> — <translate><!--T:103--> Remove the hatnote and <tvar name=1>{{tag|div|open}}</tvar> tags around the excerpt, to use it inside other text.</translate> * <code>references=no</code> — <translate><!--T:104--> Remove all references.</translate> * <code>subsections=yes</code> — <translate><!--T:105--> Include subsections of the transcluded section. Notice that if the transclusion is done from a section level 3, and the transcluded subsections are level 3 too, then the transcluded subsections will show with the same hierarchy as the transcluding section, which is probably not desirable, so use with caution.</translate> <translate> === Replacing a section with an excerpt === <!--T:65--> </translate> [[File:How to excerpt.webm|thumb|<translate><!--T:66--> How to replace a section with an excerpt.</translate>]] <translate><!--T:67--> A section is often a summary of a more precise page dealing with a subtopic.</translate> <translate><!--T:68--> Sometimes it's convenient to replace the content of such a section with an excerpt of the page about the subtopic, after merging the original content of the section (if any) into the page about the subtopic.</translate> <translate><!--T:69--> This improves both the page about the subtopic and the section, reduces maintenance, drives contributors to collaborate, etc.</translate> <translate><!--T:70--> An efficient way to proceed is:</translate> <translate> <!--T:71--> # Open the section for editing in one tab, and the page about the subtopic in another.</translate> <translate> <!--T:73--> # Copy the text of the section and append it to the lead of the page about the subtopic.</translate> <translate> <!--T:74--> # Consolidate and adjust the combined lead using common sense.</translate> <translate> <!--T:75--> # Save the changes in the child article with an edit summary like: Copied content from <tvar name=1><nowiki>[[Page]]</nowiki></tvar>; see that article's history for attribution.</translate> <translate> <!--T:76--> # Back in the section, delete all content and replace it with an excerpt of the page about the subtopic.</translate> <translate> <!--T:77--> # Save the changes in the section with an edit summary like: Move content to <tvar name=1><nowiki>[[page about the subtopic]]</nowiki></tvar> and leave an excerpt. == Excerpt trees == <!--T:122--> </translate> [[File:Excerpt tree.png|thumb|<translate><!--T:123--> Visual representation of an imaginary excerpt tree.</translate>]] <translate> <!--T:124--> When a very general article uses excerpts from more specific articles, which in turn use excerpts from even more specific articles, then a [[w:Tree structure|tree structure]] emerges, called an "Excerpt tree". </translate> <translate><!--T:125--> Below you can navigate the main excerpt trees on this wiki.</translate> <translate><!--T:126--> It's useful for editors interested in expanding or improving them.</translate> {{Excerpt tree| * [[Architecture Repository]] * [[Platform Engineering Team]] }} <translate> == Examples == <!--T:78--> === Lead section === <!--T:79--> </translate> <pre>{{Excerpt|Lorem ipsum}}</pre> {{Excerpt|Lorem ipsum}} {{Reflist}} {{Clear}} <translate> === Specific section === <!--T:84--> </translate> <pre>{{Excerpt|Lorem ipsum|Section}}</pre> {{Excerpt|Lorem ipsum|Section}} <translate> === Files only === <!--T:81--> </translate> <pre>{{Excerpt|Lorem ipsum|only=files|hat=no}}</pre> {{Excerpt|Lorem ipsum|only=files|hat=no}} {{Clear}} <translate> === Infobox only === <!--T:97--> </translate> <pre>{{Excerpt|Extension:CategoryLockdown|only=templates|templates=Extension|this=This infobox is}}</pre> {{Excerpt|Extension:CategoryLockdown|only=templates|templates=Extension|this=This infobox is}} {{Clear}} <translate> === No infobox === <!--T:98--> </translate> <pre>{{Excerpt|Extension:CategoryLockdown|templates=-Extension}}</pre> {{Excerpt|Extension:CategoryLockdown|templates=-Extension}} <translate> === Portal === <!--T:85--> </translate> <pre>{{Excerpt|Lorem ipsum|files=1|references=no|hat=no|more=yes}}</pre> {{Excerpt|Lorem ipsum|files=1|references=no|hat=no|more=yes}} {{Clear}} <translate> == See also == <!--T:82--> </translate> * [[Module:Transcluder]] * [[Module:Excerpt]] * [[Module:Excerpt/config]] * [[c:Data:I18n/Module:Excerpt.tab]] <translate> == Template data == <!--T:83--> </translate> {{#invoke:TNT|doc|Excerpt}} }} </noinclude> f84bb782c5a6bc07a0998f73aa8ebab67f1f6978 MediaWiki:MonoBook.css 8 16 32 2024-04-03T15:54:35Z Nulcow 2 Nulcow moved page [[MediaWiki:MonoBook.css]] to [[MediaWiki:Monobook.css]]: Misspelled title css text/css /* #REDIRECT */@import url(https://196.miraheze.org/wiki/MediaWiki:Monobook.css?action=raw&ctype=text/css); db41508d7825afb92f10640078b8cdd925dbf718 Module:Documentation/i18n 828 17 35 2024-04-03T16:23:35Z Nulcow 2 Created page with "local format = require('Module:TNT').format local i18n = {} i18n['cfg-error-msg-type'] = format('I18n/Documentation', 'cfg-error-msg-type') i18n['cfg-error-msg-empty'] = format('I18n/Documentation', 'cfg-error-msg-empty') -- cfg['template-namespace-heading'] -- The heading shown in the template namespace. i18n['template-namespace-heading'] = format('I18n/Documentation', 'template-namespace-heading') -- cfg['module-namespace-heading'] -- The heading shown in the module..." Scribunto text/plain local format = require('Module:TNT').format local i18n = {} i18n['cfg-error-msg-type'] = format('I18n/Documentation', 'cfg-error-msg-type') i18n['cfg-error-msg-empty'] = format('I18n/Documentation', 'cfg-error-msg-empty') -- cfg['template-namespace-heading'] -- The heading shown in the template namespace. i18n['template-namespace-heading'] = format('I18n/Documentation', 'template-namespace-heading') -- cfg['module-namespace-heading'] -- The heading shown in the module namespace. i18n['module-namespace-heading'] = format('I18n/Documentation', 'module-namespace-heading') -- cfg['file-namespace-heading'] -- The heading shown in the file namespace. i18n['file-namespace-heading'] = format('I18n/Documentation', 'file-namespace-heading') -- cfg['other-namespaces-heading'] -- The heading shown in other namespaces. i18n['other-namespaces-heading'] = format('I18n/Documentation', 'other-namespaces-heading') -- cfg['view-link-display'] -- The text to display for "view" links. i18n['view-link-display'] = format('I18n/Documentation', 'view-link-display') -- cfg['edit-link-display'] -- The text to display for "edit" links. i18n['edit-link-display'] = format('I18n/Documentation', 'edit-link-display') -- cfg['history-link-display'] -- The text to display for "history" links. i18n['history-link-display'] = format('I18n/Documentation', 'history-link-display') -- cfg['purge-link-display'] -- The text to display for "purge" links. i18n['purge-link-display'] = format('I18n/Documentation', 'purge-link-display') -- cfg['create-link-display'] -- The text to display for "create" links. i18n['create-link-display'] = format('I18n/Documentation', 'create-link-display') return i18n 9a9f234b177a424f1fc465eb25c484eff54905c0 Module:Transcluder 828 18 36 2024-04-03T16:24:37Z Nulcow 2 Created page with "-- Module:Transcluder is a general-purpose transclusion engine -- Documentation and master version: https://en.wikipedia.org/wiki/Module:Transcluder -- Authors: User:Sophivorus, User:Certes & others -- License: CC-BY-SA-3.0 local p = {} -- Helper function to test for truthy and falsy values -- @todo Somehow internationalize it local function truthy(value) if not value or value == '' or value == 0 or value == '0' or value == 'false' or value == 'no' or value == 'non' t..." Scribunto text/plain -- Module:Transcluder is a general-purpose transclusion engine -- Documentation and master version: https://en.wikipedia.org/wiki/Module:Transcluder -- Authors: User:Sophivorus, User:Certes & others -- License: CC-BY-SA-3.0 local p = {} -- Helper function to test for truthy and falsy values -- @todo Somehow internationalize it local function truthy(value) if not value or value == '' or value == 0 or value == '0' or value == 'false' or value == 'no' or value == 'non' then return false end return true end -- Helper function to match from a list of regular expressions -- Like so: match pre..list[1]..post or pre..list[2]..post or ... local function matchAny(text, pre, list, post, init) local match = {} for i = 1, #list do match = { mw.ustring.match(text, pre .. list[i] .. post, init) } if match[1] then return unpack(match) end end return nil end -- Like matchAny but for Category/File links with less overhead local function matchAnyLink(text, list) local match for _, v in ipairs(list) do match = string.match(text, '%[%[%s*' .. v .. '%s*:.*%]%]') if match then break end end return match end -- Helper function to escape a string for use in regexes local function escapeString(str) return string.gsub(str, '[%^%$%(%)%.%[%]%*%+%-%?%%]', '%%%0') end -- Helper function to remove a string from a text local function removeString(text, str) local pattern = escapeString(str) if #pattern > 9999 then -- strings longer than 10000 bytes can't be put into regexes pattern = escapeString(mw.ustring.sub(str, 1, 999)) .. '.-' .. escapeString(mw.ustring.sub(str, -999)) end return string.gsub(text, pattern, '') end -- Helper function to convert a comma-separated list of numbers or min-max ranges into a list of booleans -- @param flags Comma-separated list of numbers or min-max ranges, for example '1,3-5' -- @return Map from integers to booleans, for example {1=true,2=false,3=true,4=true,5=true} -- @return Boolean indicating whether the flags should be treated as a blacklist or not local function parseFlags(value) local flags = {} local blacklist = false if not value then return nil, false end if type(value) == 'number' then if value < 0 then value = -value blacklist = true end flags = { [value] = true } elseif type(value) == 'string' then if string.sub(value, 1, 1) == '-' then blacklist = true value = string.sub(value, 2) end local ranges = mw.text.split(value, ',') -- split ranges: '1,3-5' to {'1','3-5'} for _, range in pairs(ranges) do range = mw.text.trim(range) local min, max = mw.ustring.match(range, '^(%d+)%s*[-–—]%s*(%d+)$') -- '3-5' to min=3 max=5 if not max then min, max = string.match(range, '^((%d+))$') end -- '1' to min=1 max=1 if max then for i = min, max do flags[i] = true end else flags[range] = true -- if we reach this point, the string had the form 'a,b,c' rather than '1,2,3' end end -- List has the form { [1] = false, [2] = true, ['c'] = false } -- Convert it to { [1] = true, [2] = true, ['c'] = true } -- But if ANY value is set to false, treat the list as a blacklist elseif type(value) == 'table' then for i, v in pairs(value) do if v == false then blacklist = true end flags[i] = true end end return flags, blacklist end -- Helper function to see if a value matches any of the given flags local function matchFlag(value, flags) if not value then return false end value = tostring(value) local lang = mw.language.getContentLanguage() local lcvalue = lang:lcfirst(value) local ucvalue = lang:ucfirst(value) for flag in pairs(flags) do if value == tostring(flag) or lcvalue == flag or ucvalue == flag or ( not tonumber(flag) and mw.ustring.match(value, flag) ) then return true end end end -- Helper function to convert template arguments into an array of options fit for get() local function parseArgs(frame) local args = {} for key, value in pairs(frame:getParent().args) do args[key] = value end for key, value in pairs(frame.args) do args[key] = value end -- args from Lua calls have priority over parent args from template return args end -- Error handling function -- Throws a Lua error or returns an empty string if error reporting is disabled local function throwError(key, value) local TNT = require('Module:TNT') local ok, message = pcall(TNT.format, 'I18n/Module:Transcluder.tab', 'error-' .. key, value) if not ok then message = key end error(message, 2) end -- Error handling function -- Returns a wiki friendly error or an empty string if error reporting is disabled local function getError(key, value) local TNT = require('Module:TNT') local ok, message = pcall(TNT.format, 'I18n/Module:Transcluder.tab', 'error-' .. key, value) if not ok then message = key end message = mw.html.create('div'):addClass('error'):wikitext(message) return message end -- Helper function to get the local name of a namespace and all its aliases -- @param name Canonical name of the namespace, for example 'File' -- @return Local name of the namespace and all aliases, for example {'File','Image','Archivo','Imagen'} local function getNamespaces(name) local namespaces = mw.clone(mw.site.namespaces[name].aliases) -- Clone because https://en.wikipedia.org/w/index.php?diff=1056921358 table.insert(namespaces, mw.site.namespaces[name].name) table.insert(namespaces, mw.site.namespaces[name].canonicalName) return namespaces end -- Get the page wikitext, following redirects -- Also returns the page name, or the target page name if a redirect was followed, or false if no page was found -- For file pages, returns the content of the file description page local function getText(page, noFollow) local title = mw.title.new(page) if not title then return false, false end local target = title.redirectTarget if target and not noFollow then title = target end local text = title:getContent() if not text then return false, title.prefixedText end -- Remove <noinclude> tags text = string.gsub(text, '<[Nn][Oo][Ii][Nn][Cc][Ll][Uu][Dd][Ee]>.-</[Nn][Oo][Ii][Nn][Cc][Ll][Uu][Dd][Ee]>', '') -- remove noinclude bits -- Keep <onlyinclude> tags if string.find(text, 'onlyinclude') then -- avoid expensive search if possible text = text :gsub('</onlyinclude>.-<onlyinclude>', '') -- remove text between onlyinclude sections :gsub('^.-<onlyinclude>', '') -- remove text before first onlyinclude section :gsub('</onlyinclude>.*', '') -- remove text after last onlyinclude section end return text, title.prefixedText end -- Get the requested files from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of files to return, for example 2 or '1,3-5'. Omit to return all files. -- @return Sequence of strings containing the wikitext of the requested files. -- @return Original wikitext minus requested files. local function getFiles(text, flags) local files = {} local flags, blacklist = parseFlags(flags) local fileNamespaces = getNamespaces('File') local name local count = 0 for file in string.gmatch(text, '%b[]') do if matchAnyLink(file, fileNamespaces) then name = string.match(file, '%[%[[^:]-:([^]|]+)') count = count + 1 if not blacklist and ( not flags or flags[count] or matchFlag(name, flags) ) or blacklist and flags and not flags[count] and not matchFlag(name, flags) then table.insert(files, file) else text = removeString(text, file) end end end return files, text end -- Get the requested tables from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of tables to return, for example 2 or '1,3-5'. Omit to return all tables. -- @return Sequence of strings containing the wikitext of the requested tables. -- @return Original wikitext minus requested tables. local function getTables(text, flags) local tables = {} local flags, blacklist = parseFlags(flags) local id local count = 0 for t in string.gmatch('\n' .. text, '\n%b{}') do if string.sub(t, 1, 3) == '\n{|' then id = string.match(t, '\n{|[^\n]-id%s*=%s*["\']?([^"\'\n]+)["\']?[^\n]*\n') count = count + 1 if not blacklist and ( not flags or flags[count] or flags[id] ) or blacklist and flags and not flags[count] and not flags[id] then table.insert(tables, t) else text = removeString(text, t) end end end return tables, text end -- Get the requested templates from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of templates to return, for example 2 or '1,3-5'. Omit to return all templates. -- @return Sequence of strings containing the wikitext of the requested templates. -- @return Original wikitext minus requested templates. local function getTemplates(text, flags) local templates = {} local flags, blacklist = parseFlags(flags) local name local count = 0 for template in string.gmatch(text, '{%b{}}') do if string.sub(template, 1, 3) ~= '{{#' then -- skip parser functions like #if name = mw.text.trim( string.match(template, '{{([^}|\n]+)') ) -- get the template name count = count + 1 if not blacklist and ( not flags or flags[count] or matchFlag(name, flags) ) or blacklist and flags and not flags[count] and not matchFlag(name, flags) then table.insert(templates, template) else text = removeString(text, template) end end end return templates, text end -- Get the requested template parameters from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of parameters to return, for example 2 or '1,3-5'. Omit to return all parameters. -- @return Map from parameter name to value, NOT IN THE ORIGINAL ORDER -- @return Original wikitext minus requested parameters. -- @return Order in which the parameters were parsed. local function getParameters(text, flags) local parameters, parameterOrder = {}, {} local flags, blacklist = parseFlags(flags) local params, count, parts, key, value for template in string.gmatch(text, '{%b{}}') do params = string.match(template, '{{[^|}]-|(.*)}}') if params then count = 0 -- Temporarily replace pipes in subtemplates and links to avoid chaos for subtemplate in string.gmatch(params, '{%b{}}') do params = string.gsub(params, escapeString(subtemplate), string.gsub(subtemplate, ".", {["%"]="%%", ["|"]="@@:@@", ["="]="@@_@@"}) ) end for link in string.gmatch(params, '%b[]') do params = string.gsub(params, escapeString(link), string.gsub(link, ".", {["%"]="%%", ["|"]="@@:@@", ["="]="@@_@@"}) ) end for parameter in mw.text.gsplit(params, '|') do parts = mw.text.split(parameter, '=') key = mw.text.trim(parts[1]) if #parts == 1 then value = key count = count + 1 key = count else value = mw.text.trim(table.concat(parts, '=', 2)) end value = string.gsub(string.gsub(value, '@@:@@', '|'), '@@_@@', '=') if not blacklist and ( not flags or matchFlag(key, flags) ) or blacklist and flags and not matchFlag(key, flags) then table.insert(parameterOrder, key) parameters[key] = value else text = removeString(text, parameter) end end end end return parameters, text, parameterOrder end -- Get the requested lists from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of lists to return, for example 2 or '1,3-5'. Omit to return all lists. -- @return Sequence of strings containing the wikitext of the requested lists. -- @return Original wikitext minus requested lists. local function getLists(text, flags) local lists = {} local flags, blacklist = parseFlags(flags) local count = 0 for list in string.gmatch('\n' .. text .. '\n\n', '\n([*#].-)\n[^*#]') do count = count + 1 if not blacklist and ( not flags or flags[count] ) or blacklist and flags and not flags[count] then table.insert(lists, list) else text = removeString(text, list) end end return lists, text end -- Get the requested paragraphs from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of paragraphs to return, for example 2 or '1,3-5'. Omit to return all paragraphs. -- @return Sequence of strings containing the wikitext of the requested paragraphs. -- @return Original wikitext minus requested paragraphs. local function getParagraphs(text, flags) local paragraphs = {} local flags, blacklist = parseFlags(flags) -- Remove non-paragraphs local elements local temp = '\n' .. text .. '\n' elements, temp = getLists(temp, 0) -- remove lists elements, temp = getFiles(temp, 0) -- remove files temp = mw.text.trim((temp :gsub('\n%b{} *\n', '\n%0\n') -- add spacing between tables and block templates :gsub('\n%b{} *\n', '\n') -- remove tables and block templates :gsub('\n==+[^=]+==+ *\n', '\n') -- remove section titles )) -- Assume that anything remaining is a paragraph local count = 0 for paragraph in mw.text.gsplit(temp, '\n\n+') do if mw.text.trim(paragraph) ~= '' then count = count + 1 if not blacklist and ( not flags or flags[count] ) or blacklist and flags and not flags[count] then table.insert(paragraphs, paragraph) else text = removeString(text, paragraph) end end end return paragraphs, text end -- Get the requested categories from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of categories to return, for example 2 or '1,3-5'. Omit to return all categories. -- @return Sequence of strings containing the wikitext of the requested categories. -- @return Original wikitext minus requested categories. local function getCategories(text, flags) local categories = {} local flags, blacklist = parseFlags(flags) local categoryNamespaces = getNamespaces('Category') local name local count = 0 for category in string.gmatch(text, '%b[]') do if matchAnyLink(category, categoryNamespaces) then name = string.match(category, '%[%[[^:]-:([^]|]+)') count = count + 1 if not blacklist and ( not flags or flags[count] or matchFlag(name, flags) ) or blacklist and flags and not flags[count] and not matchFlag(name, flags) then table.insert(categories, category) else text = removeString(text, category) end end end return categories, text end -- Get the requested references from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of references to return, for example 2 or '1,3-5'. Omit to return all references. -- @return Sequence of strings containing the wikitext of the requested references. -- @return Original wikitext minus requested references. local function getReferences(text, flags) local references = {} -- Remove all references, including citations, when 0 references are requested -- This is kind of hacky but currently necessary because the rest of the code -- doesn't remove citations like <ref name="Foo" /> if Foo is defined elsewhere if flags and not truthy(flags) then text = string.gsub(text, '<%s*[Rr][Ee][Ff][^>/]*>.-<%s*/%s*[Rr][Ee][Ff]%s*>', '') text = string.gsub(text, '<%s*[Rr][Ee][Ff][^>/]*/%s*>', '') return references, text end local flags, blacklist = parseFlags(flags) local name local count = 0 for reference in string.gmatch(text, '<%s*[Rr][Ee][Ff][^>/]*>.-<%s*/%s*[Rr][Ee][Ff]%s*>') do name = string.match(reference, '<%s*[Rr][Ee][Ff][^>]*name%s*=%s*["\']?([^"\'>/]+)["\']?[^>]*%s*>') count = count + 1 if not blacklist and ( not flags or flags[count] or matchFlag(name, flags) ) or blacklist and flags and not flags[count] and not matchFlag(name, flags) then table.insert(references, reference) else text = removeString(text, reference) if name then for citation in string.gmatch(text, '<%s*[Rr][Ee][Ff][^>]*name%s*=%s*["\']?' .. escapeString(name) .. '["\']?[^/>]*/%s*>') do text = removeString(text, citation) end end end end return references, text end -- Get the lead section from the given wikitext. -- @param text Required. Wikitext to parse. -- @return Wikitext of the lead section. local function getLead(text) text = string.gsub('\n' .. text, '\n==.*', '') text = mw.text.trim(text) if not text then return throwError('lead-empty') end return text end -- Get the requested sections from the given wikitext. -- @param text Required. Wikitext to parse. -- @param flags Range of sections to return, for example 2 or '1,3-5'. Omit to return all sections. -- @return Sequence of strings containing the wikitext of the requested sections. -- @return Original wikitext minus requested sections. local function getSections(text, flags) local sections = {} local flags, blacklist = parseFlags(flags) local count = 0 local prefix, section, suffix for title in string.gmatch('\n' .. text .. '\n==', '\n==+%s*([^=]+)%s*==+') do count = count + 1 prefix, section, suffix = string.match('\n' .. text .. '\n==', '\n()==+%s*' .. escapeString(title) .. '%s*==+(.-)()\n==') if not blacklist and ( not flags or flags[count] or matchFlag(title, flags) ) or blacklist and flags and not flags[count] and not matchFlag(title, flags) then sections[title] = section else text = string.sub(text, 1, prefix) .. string.sub(text, suffix) text = string.gsub(text, '\n?==$', '') -- remove the trailing \n== end end return sections, text end -- Get the requested section or <section> tag from the given wikitext (including subsections). -- @param text Required. Wikitext to parse. -- @param section Required. Title of the section to get (in wikitext), for example 'History' or 'History of [[Athens]]'. -- @return Wikitext of the requested section. local function getSection(text, section) section = mw.text.trim(section) local escapedSection = escapeString(section) -- First check if the section title matches a <section> tag if string.find(text, '<%s*[Ss]ection%s+begin%s*=%s*["\']?%s*' .. escapedSection .. '%s*["\']?%s*/>') then -- avoid expensive search if possible text = mw.text.trim((text :gsub('<%s*[Ss]ection%s+end=%s*["\']?%s*'.. escapedSection ..'%s*["\']?%s*/>.-<%s*[Ss]ection%s+begin%s*=%s*["\']?%s*' .. escapedSection .. '%s*["\']?%s*/>', '') -- remove text between section tags :gsub('^.-<%s*[Ss]ection%s+begin%s*=%s*["\']?%s*' .. escapedSection .. '%s*["\']?%s*/>', '') -- remove text before first section tag :gsub('<%s*[Ss]ection%s+end=%s*["\']?%s*'.. escapedSection ..'%s*["\']?%s*/>.*', '') -- remove text after last section tag )) if text == '' then return throwError('section-tag-empty', section) end return text end local level, text = string.match('\n' .. text .. '\n', '\n(==+)%s*' .. escapedSection .. '%s*==.-\n(.*)') if not text then return throwError('section-not-found', section) end local nextSection = '\n==' .. string.rep('=?', #level - 2) .. '[^=].*' text = string.gsub(text, nextSection, '') -- remove later sections with headings at this level or higher text = mw.text.trim(text) if text == '' then return throwError('section-empty', section) end return text end -- Replace the first call to each reference defined outside of the text for the full reference, to prevent undefined references -- Then prefix the page title to the reference names to prevent conflicts -- that is, replace <ref name="Foo"> for <ref name="Title of the article Foo"> -- and also <ref name="Foo" /> for <ref name="Title of the article Foo" /> -- also remove reference groups: <ref name="Foo" group="Bar"> for <ref name="Title of the article Foo"> -- and <ref group="Bar"> for <ref> -- @todo The current regex may fail in cases with both kinds of quotes, like <ref name="Darwin's book"> local function fixReferences(text, page, full) if not full then full = getText(page) end local refNames = {} local refName local refBody local position = 1 while position < mw.ustring.len(text) do refName, position = mw.ustring.match(text, '<%s*[Rr][Ee][Ff][^>]*name%s*=%s*["\']?([^"\'>]+)["\']?[^>]*/%s*>()', position) if refName then refName = mw.text.trim(refName) if not refNames[refName] then -- make sure we process each ref name only once table.insert(refNames, refName) refName = escapeString(refName) refBody = mw.ustring.match(text, '<%s*[Rr][Ee][Ff][^>]*name%s*=%s*["\']?%s*' .. refName .. '%s*["\']?[^>/]*>.-<%s*/%s*[Rr][Ee][Ff]%s*>') if not refBody then -- the ref body is not in the excerpt refBody = mw.ustring.match(full, '<%s*[Rr][Ee][Ff][^>]*name%s*=%s*["\']?%s*' .. refName .. '%s*["\']?[^/>]*>.-<%s*/%s*[Rr][Ee][Ff]%s*>') if refBody then -- the ref body was found elsewhere text = mw.ustring.gsub(text, '<%s*[Rr][Ee][Ff][^>]*name%s*=%s*["\']?%s*' .. refName .. '%s*["\']?[^>]*/?%s*>', mw.ustring.gsub(refBody, '%%', '%%%%'), 1) end end end else position = mw.ustring.len(text) end end page = string.gsub(page, '"', '') -- remove any quotation marks from the page title text = mw.ustring.gsub(text, '<%s*[Rr][Ee][Ff][^>]*name%s*=%s*["\']?([^"\'>/]+)["\']?[^>/]*(/?)%s*>', '<ref name="' .. page .. ' %1"%2>') text = mw.ustring.gsub(text, '<%s*[Rr][Ee][Ff]%s*group%s*=%s*["\']?[^"\'>/]+["\']%s*>', '<ref>') return text end -- Replace the bold title or synonym near the start of the page by a link to the page local function linkBold(text, page) local lang = mw.language.getContentLanguage() local position = mw.ustring.find(text, "'''" .. lang:ucfirst(page) .. "'''", 1, true) -- look for "'''Foo''' is..." (uc) or "A '''foo''' is..." (lc) or mw.ustring.find(text, "'''" .. lang:lcfirst(page) .. "'''", 1, true) -- plain search: special characters in page represent themselves if position then local length = mw.ustring.len(page) text = mw.ustring.sub(text, 1, position + 2) .. "[[" .. mw.ustring.sub(text, position + 3, position + length + 2) .. "]]" .. mw.ustring.sub(text, position + length + 3, -1) -- link it else -- look for anything unlinked in bold, assumed to be a synonym of the title (e.g. a person's birth name) text = mw.ustring.gsub(text, "()'''(.-'*)'''", function(a, b) if not mw.ustring.find(b, "%[") and not mw.ustring.find(b, "%{") then -- if not wikilinked or some weird template return "'''[[" .. page .. "|" .. b .. "]]'''" -- replace '''Foo''' by '''[[page|Foo]]''' else return nil -- instruct gsub to make no change end end, 1) -- "end" here terminates the anonymous replacement function(a, b) passed to gsub end return text end -- Remove non-free files. -- @param text Required. Wikitext to clean. -- @return Clean wikitext. local function removeNonFreeFiles(text) local fileNamespaces = getNamespaces('File') local fileName local fileDescription local frame = mw.getCurrentFrame() for file in string.gmatch(text, '%b[]') do if matchAnyLink(file, fileNamespaces) then fileName = 'File:' .. string.match(file, '%[%[[^:]-:([^]|]+)') fileDescription, fileName = getText(fileName) if fileName then if not fileDescription or fileDescription == '' then fileDescription = frame:preprocess('{{' .. fileName .. '}}') -- try Commons end if fileDescription and string.match(fileDescription, '[Nn]on%-free') then text = removeString(text, file) end end end end return text end -- Remove any self links local function removeSelfLinks(text) local lang = mw.language.getContentLanguage() local page = escapeString(mw.title.getCurrentTitle().prefixedText) local ucpage = lang:ucfirst(page) local lcpage = lang:lcfirst(page) text = text :gsub('%[%[(' .. ucpage .. ')%]%]', '%1') :gsub('%[%[(' .. lcpage .. ')%]%]', '%1') :gsub('%[%[' .. ucpage .. '|([^]]+)%]%]', '%1') :gsub('%[%[' .. lcpage .. '|([^]]+)%]%]', '%1') return text end -- Remove all wikilinks local function removeLinks(text) text = text :gsub('%[%[[^%]|]+|([^]]+)%]%]', '%1') :gsub('%[%[([^]]+)%]%]', '%1') :gsub('%[[^ ]+ ([^]]+)%]', '%1') :gsub('%[([^]]+)%]', '%1') return text end -- Remove HTML comments local function removeComments(text) text = string.gsub(text, '<!%-%-.-%-%->', '') return text end -- Remove behavior switches, such as __NOTOC__ local function removeBehaviorSwitches(text) text = string.gsub(text, '__[A-Z]+__', '') return text end -- Remove bold text local function removeBold(text) text = string.gsub(text, "'''", '') return text end -- Main function for modules local function get(page, options) if not options then options = {} end -- Make sure the page exists if not page then return throwError('no-page') end page = mw.text.trim(page) if page == '' then return throwError('no-page') end local page, hash, section = string.match(page, '([^#]+)(#?)(.*)') local text, temp = getText(page, options.noFollow) if not temp then return throwError('invalid-title', page) end page = temp if not text then return throwError('page-not-found', page) end local full = text -- save the full text for fixReferences below -- Get the requested section if truthy(section) then text = getSection(text, section) elseif truthy(hash) then text = getLead(text) end -- Keep only the requested elements local elements if options.only then if options.only == 'sections' then elements = getSections(text, options.sections) end if options.only == 'lists' then elements = getLists(text, options.lists) end if options.only == 'files' then elements = getFiles(text, options.files) end if options.only == 'tables' then elements = getTables(text, options.tables) end if options.only == 'templates' then elements = getTemplates(text, options.templates) end if options.only == 'parameters' then elements = getParameters(text, options.parameters) end if options.only == 'paragraphs' then elements = getParagraphs(text, options.paragraphs) end if options.only == 'categories' then elements = getCategories(text, options.categories) end if options.only == 'references' then elements = getReferences(text, options.references) end text = '' if elements then for key, element in pairs(elements) do text = text .. '\n' .. element .. '\n' end end end -- Filter the requested elements if options.sections and options.only ~= 'sections' then elements, text = getSections(text, options.sections) end if options.lists and options.only ~= 'lists' then elements, text = getLists(text, options.lists) end if options.files and options.only ~= 'files' then elements, text = getFiles(text, options.files) end if options.tables and options.only ~= 'tables' then elements, text = getTables(text, options.tables) end if options.templates and options.only ~= 'templates' then elements, text = getTemplates(text, options.templates) end if options.parameters and options.only ~= 'parameters' then elements, text = getParameters(text, options.parameters) end if options.paragraphs and options.only ~= 'paragraphs' then elements, text = getParagraphs(text, options.paragraphs) end if options.categories and options.only ~= 'categories' then elements, text = getCategories(text, options.categories) end if options.references and options.only ~= 'references' then elements, text = getReferences(text, options.references) end -- Misc options if truthy(options.fixReferences) then text = fixReferences(text, page, full) end if truthy(options.linkBold) and not truthy(section) then text = linkBold(text, page) end if truthy(options.noBold) then text = removeBold(text) end if truthy(options.noLinks) then text = removeLinks(text) end if truthy(options.noSelfLinks) then text = removeSelfLinks(text) end if truthy(options.noNonFreeFiles) then text = removeNonFreeFiles(text) end if truthy(options.noBehaviorSwitches) then text = removeBehaviorSwitches(text) end if truthy(options.noComments) then text = removeComments(text) end -- Remove multiple newlines left over from removing elements text = string.gsub(text, '\n\n\n+', '\n\n') text = mw.text.trim(text) return text end -- Main invocation function for templates local function main(frame) local args = parseArgs(frame) local page = args[1] local ok, text = pcall(get, page, args) if not ok then return getError(text) end return frame:preprocess(text) end -- Entry points for templates function p.main(frame) return main(frame) end -- Entry points for modules function p.get(page, options) return get(page, options) end function p.getText(page, noFollow) return getText(page, noFollow) end function p.getLead(text) return getLead(text) end function p.getSection(text, section) return getSection(text, section) end function p.getSections(text, flags) return getSections(text, flags) end function p.getParagraphs(text, flags) return getParagraphs(text, flags) end function p.getParameters(text, flags) return getParameters(text, flags) end function p.getCategories(text, flags) return getCategories(text, flags) end function p.getReferences(text, flags) return getReferences(text, flags) end function p.getTemplates(text, flags) return getTemplates(text, flags) end function p.getTables(text, flags) return getTables(text, flags) end function p.getLists(text, flags) return getLists(text, flags) end function p.getFiles(text, flags) return getFiles(text, flags) end function p.getError(message, value) return getError(message, value) end -- Expose handy methods function p.truthy(value) return truthy(value) end function p.parseArgs(frame) return parseArgs(frame) end function p.matchAny(text, pre, list, post, init) return matchAny(text, pre, list, post, init) end function p.matchFlag(value, flags) return matchFlag(value, flags) end function p.getNamespaces(name) return getNamespaces(name) end function p.removeBold(text) return removeBold(text) end function p.removeLinks(text) return removeLinks(text) end function p.removeSelfLinks(text) return removeSelfLinks(text) end function p.removeNonFreeFiles(text) return removeNonFreeFiles(text) end function p.removeBehaviorSwitches(text) return removeBehaviorSwitches(text) end function p.removeComments(text) return removeComments(text) end return p 0f1db2defde78554237cf201fe765d717cafaccb Rulepedia:Featured Article/April 3rd, 2024 4 19 37 2024-04-03T16:33:44Z Nulcow 2 Created page with "{{Excerpt|r/196|files=1|references=no|hat=no|more=yes}}" wikitext text/x-wiki {{Excerpt|r/196|files=1|references=no|hat=no|more=yes}} cafb4139c95bd4af90a1f4317607c592555d2024 Template:Feature 10 20 39 2024-04-03T16:38:39Z Nulcow 2 Created page with "{{Excerpt|{{{1}}}|files=1|references=no|hat=no|more=yes}}" wikitext text/x-wiki {{Excerpt|{{{1}}}|files=1|references=no|hat=no|more=yes}} 6045a26b0dde3b4be2b04a807d2601e2ec64dde4 Rulepedia:Featured Article/April 2, 2024 4 21 40 2024-04-03T16:39:10Z Nulcow 2 Created page with "{{Template:Feature|r/196}}" wikitext text/x-wiki {{Template:Feature|r/196}} 15356580dc0fba3926a6def006e7ce8bb3da2cdb 42 40 2024-04-03T16:42:16Z Nulcow 2 wikitext text/x-wiki {{Template:Feature|R/196}} 05437883a7fb5ea142613ee600188b5ad3c471ae R/196 0 22 41 2024-04-03T16:41:57Z Nulcow 2 Stubby article about the 196 subreddit wikitext text/x-wiki r/196 is the first 196 subreddit, and the origin of the 196 community that has since spread to other platforms. 580168f93ce80cd18560d93a40cc6568b21117e3 File:196home.png 6 23 44 2024-04-03T17:14:26Z Nulcow 2 wikitext text/x-wiki A screenshot of r/196 taken on April 3rd, 2024. e0716cf1119454a5ce684a71b56a8c7b0393cba2 Template:PTTC 10 24 45 2024-04-03T17:18:23Z Nulcow 2 Created page with "''Due to technical constraints, the title of this page does not match the intended capitalisation of its subject's name; it should be "{{{1}}}".''" wikitext text/x-wiki ''Due to technical constraints, the title of this page does not match the intended capitalisation of its subject's name; it should be "{{{1}}}".'' 48c9788302b948a95b12646d9f79cb506ea7a902 46 45 2024-04-03T17:19:30Z Nulcow 2 wikitext text/x-wiki ''Due to technical constraints, the title of this page does not match the intended capitalisation of its subject's name; it should be "{{{1}}}".'' <br> 94bec056e2545acfed0a19ef2e7007b3d3079d1e Template:Stub 10 25 47 2024-04-03T17:22:40Z Nulcow 2 Created page with "{{asbox | image = | pix = | subject = | article = article | qualifier = | category = Stubs | tempsort = no | lowercase = y | name = Template:Stub }}" wikitext text/x-wiki {{asbox | image = | pix = | subject = | article = article | qualifier = | category = Stubs | tempsort = no | lowercase = y | name = Template:Stub }} c8372a9cd3ab0d8ef30c901442b93e0675510604 53 47 2024-04-03T17:30:53Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Stub]] wikitext text/x-wiki {{asbox | image = | pix = | subject = | article = article | qualifier = | category = Stubs | tempsort = no | lowercase = y | name = Template:Stub }} c8372a9cd3ab0d8ef30c901442b93e0675510604 Template:Asbox 10 26 48 2024-04-03T17:23:01Z Nulcow 2 Created page with "<includeonly>{{#invoke:Asbox|main}}</includeonly><noinclude> {{documentation}} <!-- Add categories to the /doc subpage and interwikis to Wikidata. --> </noinclude>" wikitext text/x-wiki <includeonly>{{#invoke:Asbox|main}}</includeonly><noinclude> {{documentation}} <!-- Add categories to the /doc subpage and interwikis to Wikidata. --> </noinclude> b20553d60f223a0f36a3089524989e235d379b74 Module:Asbox 828 27 49 2024-04-03T17:24:20Z Nulcow 2 Created page with "--[[ This module was created by User:CodeHydro (Alexander Zhikun He). User:Jackmcbarn and User:Mr._Stradivarius provided a great deal of assistance in writting p.main() p.main() draw heavily from the following version of Template:Asbox of the English Wikipedia, authored primarily by User:Rich_Farmbrough https://en.wikipedia.org/w/index.php?title=Template:Asbox&oldid=619510287 p.templatepage() is derived from the following revision of Template:Asbox/templatepage, author..." Scribunto text/plain --[[ This module was created by User:CodeHydro (Alexander Zhikun He). User:Jackmcbarn and User:Mr._Stradivarius provided a great deal of assistance in writting p.main() p.main() draw heavily from the following version of Template:Asbox of the English Wikipedia, authored primarily by User:Rich_Farmbrough https://en.wikipedia.org/w/index.php?title=Template:Asbox&oldid=619510287 p.templatepage() is derived from the following revision of Template:Asbox/templatepage, authored primarily by User:MSGJ https://en.wikipedia.org/w/index.php?title=Template:Asbox/templatepage&oldid=632914791 Both templates had significant contributions from numerous others listed in the revision history tab of their respective pages. --]] local WRAPPER_TEMPLATE, args = 'Template:Asbox' local templatestyles = 'Asbox/styles.css' local p, Buffer, stubCats = { --Prevents dupli-cats... get it? Maybe not? cats = setmetatable({}, {__newindex = function(t, i, v) if not rawget(t, i) then rawset(t, i, v) table.insert(t, i) end end}), --initializes variables required by both p.main and p.templatepage init = function(self, frame, page) args, page = args or require('Module:Arguments').getArgs(frame, { wrappers = WRAPPER_TEMPLATE }), page or mw.title.getCurrentTitle() --Ensures demo parameter will never affect category() output for articles self.demo = self.demo or page.namespace ~= 0 and args.demo return args, page end }, require('Module:Buffer') --[[ Formats category links. Stores them until called with cat.done=true Takes multiple or single categories in the form of 'cat' or a table of strings and/or tables containing parts. (See below) ]] local attention, catTag, catKey = Buffer'Stub message templates needing attention', '[[Category:%s]]', '%s|%s%s' local function category(cat) for _, v in ipairs((tostring(cat) == cat or cat.t) and {cat} or cat) do --[[ If v is a table: [1] = full category name; defaults to local attention if blank k = Category sort key. Prefix before v.t t = page.text or args.tempsort#; appended after k (or in its place if omitted). Required if v is not a string Basically the same as v = (v[1] or attention) .. ' | ' .. (v.k or '') .. v.t ]] if v and v ~= true then--reject v = nil, false, or true p.cats[catTag:format(tostring(v) == v and v or (v[1] and Buffer(v[1]) or attention):_in(v.k):_(v.t):_str(2, nil, nil, '|') )] = true end end return cat.done and table.concat(p.cats, p.demo and ' | ' or nil) or '' end --[[ Makes an ombox warning; Takes table {ifNot = Boolean, text, {cat. sort key, cat. sort name}} Will return an empty string instead when ifNot evaluates to true ]] local function ombox(v) if v.ifNot then return end p.ombox = p.ombox or require('Module:Message box').ombox category{v[2]} return p.ombox{ type = 'content', text = v[1] } end --[[ Unlike original template, module now takes unlimited cats! This function also performs most stub category error checks except for the ombox for when main |category= is omitted (See p.template()) ]] local function catStub(page, pageDoc) stubCats = {missing = {}, v = {}} -- zwj and zwnj have semantical use in other other wikis, don't remove them local zwj = '\226\128\141' -- U+200D, E2 80 8D local zwnj = '\226\128\140' -- U+200C, E2 80 8C local disallowedUnicodeChars = '[^%w%p%s' .. zwj .. zwnj .. ']' -- for i18n we make this a separate string local code for k, _ in pairs(args) do --Find category parameters and store the number (main cat = '') table.insert(stubCats, string.match(k, '^category(%d*)$')) end table.sort(stubCats) for k, v in ipairs(stubCats) do --Get category names and, if called by p.templatepage, the optional sort key local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], disallowedUnicodeChars, '')--remove all hidden unicode chars --Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category. table.insert(stubCats.v, page and (--p.templatepage passes page; p.main does not, i.e. articles are categorized without sort keys. v=='' and tsort == 'no'--if true, inserts 'true' in table, which category() will reject or tsort and {cat, k = ' ', t = tsort} or {cat, k = ' *', t = page.text}--note space in front of sort key ) or cat ) --Check category existance only if on the template page (i.e. stub documentation) if page then if not mw.title.new('Category:' .. cat).exists then code = code or mw.html.create'code':wikitext'|category' table.insert(stubCats.missing, tostring(mw.clone(code):wikitext(v))) end --[[ Checks non-demo stub template for documentation and flags if doc is present. All stub cats names are checked and flagged if it does not match 'Category: [] stub'. The main stub cat is exempt from the name check if the stub template has its own doc (presumably, this doc would have an explanation as to why the main stub cat is non-conforming). ]] table.insert(stubCats.v, v == '' and not p.demo and pageDoc.exists and 'Stub message templates with documentation subpages' or not cat:match' stubs$' and {k = 'S', t = page.text} ) end end --Add category names after loop is completed category(stubCats.v) return #stubCats.missing > 0 and ombox{ --Changed, original msg: --One or more of the stub categories defined in this template do not seem to exist! --Please double-check the parameters {{para|category}}, {{para|category1}} and {{para|category2}}. 'The following parameter' .. (#stubCats.missing == 1 and ' defines a stub category that does' or 's define stub categories that do') .. ' not exist: ' .. mw.text.listToText(stubCats.missing), {k = 'N', t = page.text} } end --Shows population of categories found by catStub(). Outputs demo values if none local function population() local wikitext, base = {}, '* [[:Category:%s]] (population: %s)\n' if not args.category and stubCats[1] ~= false then table.insert(stubCats, 1, false) end for _, v in ipairs(stubCats) do table.insert(wikitext, base:format( v and args['category' .. v] or '{{{category}}}', v and mw.site.stats.pagesInCategory(args['category' .. v], 'all') or 0 )) end return table.concat(wikitext) end --Includes standard stub documention and flags stub templates with bad parameter values. function p.templatepage(frame, page) args, page = p:init(frame, page) local tStubDoc = mw.title.new'Template:Stub documentation' local pageDoc = page:subPageTitle('doc') --Reorganization note: Original Asbox alternates between outputting categories and checking on params |category#=. --Rather than checking multiple times and switching tasks, all stub category param operations have been rolled into catStub() return Buffer( ombox{--Show ombox warnings for missing args. ifNot = args.category, 'The <code>|category</code> parameter is not set. Please add an appropriate stub category.', {k = 'C', t = page.text} }) :_(ombox{ ifNot = args.subject or args.article or args.qualifier, 'This stub template contains no description! At least one of the parameters <code>|subject</code>, <code>|article</code> or <code>|qualifier</code> must be defined.', {k = 'D', t = page.text} }) :_(catStub(page, pageDoc))--catStub() may also return an ombox if there are non-existing categories :_(category{ done = p.demo ~= 'doc',--Outputs categories if not doc demo 'Stub message templates', args.icon and 'Stub message templates using icon parameter' or args.image and ( mw.title.new('Media:' .. mw.text.split(args.image, '|')[1]).exists--do nothing if exists. category() will reject true or {k = 'B', t = page.text} ) or 'Stub message templates without images', args.imagealt and {k = 'I', t = page.text}, }) :_((not p.demo or p.demo == 'doc') and--Add standard stub template documentation require('Module:Documentation').main{ content = Buffer(page.text ~= 'Stub' and--This comparison performed in {{Asbox/stubtree}} before it invokes Module:Asbox stubtree require('Module:Asbox stubtree').subtree{args = {pagename = page.text}} ) :_in'\n== About this template ==\nThis template is used to identify a':_(args.subject):_'stub':_(args.qualifier):_out' '--space :_'. It uses {{[[Template:Asbox|asbox]]}}, which is a meta-template designed to ease the process of creating and maintaining stub templates.\n=== Usage ===\nTyping ' :_(mw.html.create'code' :wikitext('{{', page.text == 'Stub' and 'stub' or page.text, '}}') ) :_' produces the message shown at the beginning, and adds the article to the following categor' :_(#stubCats > 1 and 'ies' or 'y') :_':\n' :_(population()) :_(pageDoc.exists and--transclusion of /doc if it exists frame:expandTemplate{title = pageDoc.text} ) :_'\n== General information ==\n' :_(frame:expandTemplate{title = tStubDoc.text}) :_'\n\n'(), ['link box'] = Buffer'This documentation is automatically generated by [[Module:Asbox]].' :_in'The general information is transcluded from [[Template:Stub documentation]]. ' :_(mw.html.create'span' :cssText'font-size:smaller;font-style:normal;line-height:130%' :node(('([%s edit] | [%s history])'):format( tStubDoc:fullUrl('action=edit', 'relative'), tStubDoc:fullUrl('action=history', 'relative') )) ) :_out() :_(page.protectionLevels.edit and page.protectionLevels.edit[1] == 'sysop' and "This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template's [" .. pageDoc:fullUrl('action=edit&preload=Template:Category_interwiki/preload', 'relative') .. '| /doc] subpage, which is not protected.' )' <br/>' } )() end function p.main(frame, page) args, page = p:init(frame, page) local output = mw.html.create'div' :attr{role = 'note'} :addClass'metadata plainlinks asbox stub' :tag'table' :attr{role = 'presentation'} :tag'tr' :addClass'noresize' :node((args.icon or args.image) and mw.html.create'td' :wikitext(args.icon or ('[[File:%s|%spx|alt=%s]]'):format( args.image or '', args.pix or '40x30', args.imagealt or 'Stub icon' )) ) :tag'td' :tag'p' :addClass'asbox-body' :wikitext( Buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space ' is a [[Wikipedia:stub|stub]]. You can help Wikipedia by [', page:fullUrl('action=edit', 'relative'), ' expanding it].' ) :done() :node(args.note and mw.html.create() :tag'p' :addClass'asbox-note' :wikitext(args.note) :done() ) :allDone() :node(args.name and require'Module:Navbar'._navbar{ args.name, mini = 'yes', } ) --[[ Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories. Articles using the template do not need a sort key since they have unique names. When p.demo equals 'doc', the demo stub categories will appear as those for a stub template. Otherwise, any non-nil p.demo will emulate article space categories (plus any error cats unless set to 'art') ]] if page.namespace == 0 then -- Main namespace category'All stub articles' catStub() elseif p.demo then if p.demo ~= 'doc' then catStub() end --Unless p.demo is set to 'art', it will also include error categories normally only shown on --the template but not in the article. The elseif after namespace == 0 means demo cats will never show in article space. p.demodoc = p.demo ~= 'art' and p.templatepage(frame, page) output = mw.html.create() :node(output) :tag'small':wikitext( 'Demo categories: ', (category{done = true}:gsub('(%[%[)(Category:)([^|%]]-)(%|)', '%1%2%3|%2%3%4'):gsub('(%[%[)(Category:)', '%1:%2')) ):done() :wikitext(p.demo == 'doc' and p.demodoc or nil) else --Checks for valid name; emulates original template's check using {{FULLPAGENAME:{{{name|}}}}} local normalizedName = mw.title.new(args.name or '') if normalizedName and normalizedName.fullText == page.fullText then output = mw.html.create():node(output):wikitext(p.templatepage(frame, page)) elseif not page.isSubpage and page.namespace == 10 then-- Template namespace and not a subpage category{{k = args.name and 'E' or 'W', t = page.text}} end end return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(output:wikitext(not p.demo and category{done = true} or nil)) end return p 0a9850f35fe9b15eaadd5d693d751ca62ddb60cf Template:Asbox/styles.css 10 28 50 2024-04-03T17:25:30Z Nulcow 2 Created page with "/* {{pp-template}} */ /* Article stub message box styles */ .asbox { position: relative; overflow:hidden; } .asbox table { background: transparent; } .asbox p { margin: 0; } .asbox p + p { margin-top: 0.25em; } .asbox-body { font-style: italic; } .asbox-note { font-size: smaller; } .asbox .navbar { position: absolute; top: -0.75em; right: 1em; display: none; }" sanitized-css text/css /* {{pp-template}} */ /* Article stub message box styles */ .asbox { position: relative; overflow:hidden; } .asbox table { background: transparent; } .asbox p { margin: 0; } .asbox p + p { margin-top: 0.25em; } .asbox-body { font-style: italic; } .asbox-note { font-size: smaller; } .asbox .navbar { position: absolute; top: -0.75em; right: 1em; display: none; } 9f0904fdac11fd6eebd84c73d5680f09d19c9b5a Module:Documentation/styles.css 828 29 51 2024-04-03T17:27:50Z Nulcow 2 Created page with "/* {{pp|small=yes}} */ .documentation, .documentation-metadata { border: 1px solid #a2a9b1; background-color: #ecfcf4; clear: both; } .documentation { margin: 1em 0 0 0; padding: 1em; } .documentation-metadata { margin: 0.2em 0; /* same margin left-right as .documentation */ font-style: italic; padding: 0.4em 1em; /* same padding left-right as .documentation */ } .documentation-startbox { padding-bottom: 3px; border-bottom: 1px solid #aaa; margin-bott..." sanitized-css text/css /* {{pp|small=yes}} */ .documentation, .documentation-metadata { border: 1px solid #a2a9b1; background-color: #ecfcf4; clear: both; } .documentation { margin: 1em 0 0 0; padding: 1em; } .documentation-metadata { margin: 0.2em 0; /* same margin left-right as .documentation */ font-style: italic; padding: 0.4em 1em; /* same padding left-right as .documentation */ } .documentation-startbox { padding-bottom: 3px; border-bottom: 1px solid #aaa; margin-bottom: 1ex; } .documentation-heading { font-weight: bold; font-size: 125%; } .documentation-clear { /* Don't want things to stick out where they shouldn't. */ clear: both; } .documentation-toolbar { font-style: normal; font-size: 85%; } html.skin-theme-clientpref-night .documentation, html.skin-theme-clientpref-night .documentation-metadata { background-color: inherit; } @media (prefers-color-scheme: dark) { html.skin-theme-clientpref-os .documentation, html.skin-theme-clientpref-os .documentation-metadata { background-color: inherit; } } a086e12b14e61c1254b77cddf71625c15359e806 Module:Yesno 828 11 55 24 2024-04-03T17:30:54Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Yesno]] Scribunto text/plain -- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}. return function (val, default) -- If your wiki uses non-ascii characters for any of "yes", "no", etc., you -- should replace "val:lower()" with "mw.ustring.lower(val)" in the -- following line. val = type(val) == 'string' and val:lower() or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y' or val == 'true' or val == 't' or val == 'on' or tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n' or val == 'false' or val == 'f' or val == 'off' or tonumber(val) == 0 then return false else return default end end f767643e7d12126d020d88d662a3dd057817b9dc Module:Arguments 828 9 57 22 2024-04-03T17:30:54Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Arguments]] Scribunto text/plain -- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke directly. local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType local arguments = {} -- Generate four different tidyVal functions, so that we don't have to check the -- options every time we call it. local function tidyValDefault(key, val) if type(val) == 'string' then val = val:match('^%s*(.-)%s*$') if val == '' then return nil else return val end else return val end end local function tidyValTrimOnly(key, val) if type(val) == 'string' then return val:match('^%s*(.-)%s*$') else return val end end local function tidyValRemoveBlanksOnly(key, val) if type(val) == 'string' then if val:find('%S') then return val else return nil end else return val end end local function tidyValNoChange(key, val) return val end local function matchesTitle(given, title) local tp = type( given ) return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title end local translate_mt = { __index = function(t, k) return k end } function arguments.getArgs(frame, options) checkType('getArgs', 1, frame, 'table', true) checkType('getArgs', 2, options, 'table', true) frame = frame or {} options = options or {} --[[ -- Set up argument translation. --]] options.translate = options.translate or {} if getmetatable(options.translate) == nil then setmetatable(options.translate, translate_mt) end if options.backtranslate == nil then options.backtranslate = {} for k,v in pairs(options.translate) do options.backtranslate[v] = k end end if options.backtranslate and getmetatable(options.backtranslate) == nil then setmetatable(options.backtranslate, { __index = function(t, k) if options.translate[k] ~= k then return nil else return k end end }) end --[[ -- Get the argument tables. If we were passed a valid frame object, get the -- frame arguments (fargs) and the parent frame arguments (pargs), depending -- on the options set and on the parent frame's availability. If we weren't -- passed a valid frame object, we are being called from another Lua module -- or from the debug console, so assume that we were passed a table of args -- directly, and assign it to a new variable (luaArgs). --]] local fargs, pargs, luaArgs if type(frame.args) == 'table' and type(frame.getParent) == 'function' then if options.wrappers then --[[ -- The wrappers option makes Module:Arguments look up arguments in -- either the frame argument table or the parent argument table, but -- not both. This means that users can use either the #invoke syntax -- or a wrapper template without the loss of performance associated -- with looking arguments up in both the frame and the parent frame. -- Module:Arguments will look up arguments in the parent frame -- if it finds the parent frame's title in options.wrapper; -- otherwise it will look up arguments in the frame object passed -- to getArgs. --]] local parent = frame:getParent() if not parent then fargs = frame.args else local title = parent:getTitle():gsub('/sandbox$', '') local found = false if matchesTitle(options.wrappers, title) then found = true elseif type(options.wrappers) == 'table' then for _,v in pairs(options.wrappers) do if matchesTitle(v, title) then found = true break end end end -- We test for false specifically here so that nil (the default) acts like true. if found or options.frameOnly == false then pargs = parent.args end if not found or options.parentOnly == false then fargs = frame.args end end else -- options.wrapper isn't set, so check the other options. if not options.parentOnly then fargs = frame.args end if not options.frameOnly then local parent = frame:getParent() pargs = parent and parent.args or nil end end if options.parentFirst then fargs, pargs = pargs, fargs end else luaArgs = frame end -- Set the order of precedence of the argument tables. If the variables are -- nil, nothing will be added to the table, which is how we avoid clashes -- between the frame/parent args and the Lua args. local argTables = {fargs} argTables[#argTables + 1] = pargs argTables[#argTables + 1] = luaArgs --[[ -- Generate the tidyVal function. If it has been specified by the user, we -- use that; if not, we choose one of four functions depending on the -- options chosen. This is so that we don't have to call the options table -- every time the function is called. --]] local tidyVal = options.valueFunc if tidyVal then if type(tidyVal) ~= 'function' then error( "bad value assigned to option 'valueFunc'" .. '(function expected, got ' .. type(tidyVal) .. ')', 2 ) end elseif options.trim ~= false then if options.removeBlanks ~= false then tidyVal = tidyValDefault else tidyVal = tidyValTrimOnly end else if options.removeBlanks ~= false then tidyVal = tidyValRemoveBlanksOnly else tidyVal = tidyValNoChange end end --[[ -- Set up the args, metaArgs and nilArgs tables. args will be the one -- accessed from functions, and metaArgs will hold the actual arguments. Nil -- arguments are memoized in nilArgs, and the metatable connects all of them -- together. --]] local args, metaArgs, nilArgs, metatable = {}, {}, {}, {} setmetatable(args, metatable) local function mergeArgs(tables) --[[ -- Accepts multiple tables as input and merges their keys and values -- into one table. If a value is already present it is not overwritten; -- tables listed earlier have precedence. We are also memoizing nil -- values, which can be overwritten if they are 's' (soft). --]] for _, t in ipairs(tables) do for key, val in pairs(t) do if metaArgs[key] == nil and nilArgs[key] ~= 'h' then local tidiedVal = tidyVal(key, val) if tidiedVal == nil then nilArgs[key] = 's' else metaArgs[key] = tidiedVal end end end end end --[[ -- Define metatable behaviour. Arguments are memoized in the metaArgs table, -- and are only fetched from the argument tables once. Fetching arguments -- from the argument tables is the most resource-intensive step in this -- module, so we try and avoid it where possible. For this reason, nil -- arguments are also memoized, in the nilArgs table. Also, we keep a record -- in the metatable of when pairs and ipairs have been called, so we do not -- run pairs and ipairs on the argument tables more than once. We also do -- not run ipairs on fargs and pargs if pairs has already been run, as all -- the arguments will already have been copied over. --]] metatable.__index = function (t, key) --[[ -- Fetches an argument when the args table is indexed. First we check -- to see if the value is memoized, and if not we try and fetch it from -- the argument tables. When we check memoization, we need to check -- metaArgs before nilArgs, as both can be non-nil at the same time. -- If the argument is not present in metaArgs, we also check whether -- pairs has been run yet. If pairs has already been run, we return nil. -- This is because all the arguments will have already been copied into -- metaArgs by the mergeArgs function, meaning that any other arguments -- must be nil. --]] if type(key) == 'string' then key = options.translate[key] end local val = metaArgs[key] if val ~= nil then return val elseif metatable.donePairs or nilArgs[key] then return nil end for _, argTable in ipairs(argTables) do local argTableVal = tidyVal(key, argTable[key]) if argTableVal ~= nil then metaArgs[key] = argTableVal return argTableVal end end nilArgs[key] = 'h' return nil end metatable.__newindex = function (t, key, val) -- This function is called when a module tries to add a new value to the -- args table, or tries to change an existing value. if type(key) == 'string' then key = options.translate[key] end if options.readOnly then error( 'could not write to argument table key "' .. tostring(key) .. '"; the table is read-only', 2 ) elseif options.noOverwrite and args[key] ~= nil then error( 'could not write to argument table key "' .. tostring(key) .. '"; overwriting existing arguments is not permitted', 2 ) elseif val == nil then --[[ -- If the argument is to be overwritten with nil, we need to erase -- the value in metaArgs, so that __index, __pairs and __ipairs do -- not use a previous existing value, if present; and we also need -- to memoize the nil in nilArgs, so that the value isn't looked -- up in the argument tables if it is accessed again. --]] metaArgs[key] = nil nilArgs[key] = 'h' else metaArgs[key] = val end end local function translatenext(invariant) local k, v = next(invariant.t, invariant.k) invariant.k = k if k == nil then return nil elseif type(k) ~= 'string' or not options.backtranslate then return k, v else local backtranslate = options.backtranslate[k] if backtranslate == nil then -- Skip this one. This is a tail call, so this won't cause stack overflow return translatenext(invariant) else return backtranslate, v end end end metatable.__pairs = function () -- Called when pairs is run on the args table. if not metatable.donePairs then mergeArgs(argTables) metatable.donePairs = true end return translatenext, { t = metaArgs } end local function inext(t, i) -- This uses our __index metamethod local v = t[i + 1] if v ~= nil then return i + 1, v end end metatable.__ipairs = function (t) -- Called when ipairs is run on the args table. return inext, t, 0 end return args end return arguments 3134ecce8429b810d445e29eae115e2ae4c36c53 Template:Yesno 10 30 59 58 2024-04-03T17:30:54Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Yesno]] wikitext text/x-wiki {{<includeonly>safesubst:</includeonly>#switch: {{<includeonly>safesubst:</includeonly>lc: {{{1|¬}}} }} |no |n |f |false |off |0 = {{{no|<!-- null -->}}} | = {{{blank|{{{no|<!-- null -->}}}}}} |¬ = {{{¬|}}} |yes |y |t |true |on |1 = {{{yes|yes}}} |#default = {{{def|{{{yes|yes}}}}}} }}<noinclude> {{Documentation}} </noinclude> 629c2937bc5cf7cfe13cd2a598582af832782399 Module:Check for unknown parameters 828 31 61 60 2024-04-03T17:30:55Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Check_for_unknown_parameters]] Scribunto text/plain -- This module may be used to compare the arguments passed to the parent -- with a list of arguments, returning a specified result if an argument is -- not on the list local p = {} local function trim(s) return s:match('^%s*(.-)%s*$') end local function isnotempty(s) return s and s:match('%S') end local function clean(text) -- Return text cleaned for display and truncated if too long. -- Strip markers are replaced with dummy text representing the original wikitext. local pos, truncated local function truncate(text) if truncated then return '' end if mw.ustring.len(text) > 25 then truncated = true text = mw.ustring.sub(text, 1, 25) .. '...' end return mw.text.nowiki(text) end local parts = {} for before, tag, remainder in text:gmatch('([^\127]*)\127[^\127]*%-(%l+)%-[^\127]*\127()') do pos = remainder table.insert(parts, truncate(before) .. '&lt;' .. tag .. '&gt;...&lt;/' .. tag .. '&gt;') end table.insert(parts, truncate(text:sub(pos or 1))) return table.concat(parts) end function p._check(args, pargs) if type(args) ~= "table" or type(pargs) ~= "table" then -- TODO: error handling return end -- create the list of known args, regular expressions, and the return string local knownargs = {} local regexps = {} for k, v in pairs(args) do if type(k) == 'number' then v = trim(v) knownargs[v] = 1 elseif k:find('^regexp[1-9][0-9]*$') then table.insert(regexps, '^' .. v .. '$') end end -- loop over the parent args, and make sure they are on the list local ignoreblank = isnotempty(args['ignoreblank']) local showblankpos = isnotempty(args['showblankpositional']) local values = {} for k, v in pairs(pargs) do if type(k) == 'string' and knownargs[k] == nil then local knownflag = false for _, regexp in ipairs(regexps) do if mw.ustring.match(k, regexp) then knownflag = true break end end if not knownflag and ( not ignoreblank or isnotempty(v) ) then table.insert(values, clean(k)) end elseif type(k) == 'number' and knownargs[tostring(k)] == nil then local knownflag = false for _, regexp in ipairs(regexps) do if mw.ustring.match(tostring(k), regexp) then knownflag = true break end end if not knownflag and ( showblankpos or isnotempty(v) ) then table.insert(values, k .. ' = ' .. clean(v)) end end end -- add results to the output tables local res = {} if #values > 0 then local unknown_text = args['unknown'] or 'Found _VALUE_, ' if mw.getCurrentFrame():preprocess( "{{REVISIONID}}" ) == "" then local preview_text = args['preview'] if isnotempty(preview_text) then preview_text = require('Module:If preview')._warning({preview_text}) elseif preview == nil then preview_text = unknown_text end unknown_text = preview_text end for _, v in pairs(values) do -- Fix odd bug for | = which gets stripped to the empty string and -- breaks category links if v == '' then v = ' ' end -- avoid error with v = 'example%2' ("invalid capture index") local r = unknown_text:gsub('_VALUE_', {_VALUE_ = v}) table.insert(res, r) end end return table.concat(res) end function p.check(frame) local args = frame.args local pargs = frame:getParent().args return p._check(args, pargs) end return p 93db6d115d4328d2a5148bb42959105e367b663e Module:String 828 32 63 62 2024-04-03T17:30:55Z Nulcow 2 1 revision imported from [[:wikipedia:Module:String]] Scribunto text/plain --[[ This module is intended to provide access to basic string functions. Most of the functions provided here can be invoked with named parameters, unnamed parameters, or a mixture. If named parameters are used, Mediawiki will automatically remove any leading or trailing whitespace from the parameter. Depending on the intended use, it may be advantageous to either preserve or remove such whitespace. Global options ignore_errors: If set to 'true' or 1, any error condition will result in an empty string being returned rather than an error message. error_category: If an error occurs, specifies the name of a category to include with the error message. The default category is [Category:Errors reported by Module String]. no_category: If set to 'true' or 1, no category will be added if an error is generated. Unit tests for this module are available at Module:String/tests. ]] local str = {} --[[ len This function returns the length of the target string. Usage: {{#invoke:String|len|target_string|}} OR {{#invoke:String|len|s=target_string}} Parameters s: The string whose length to report If invoked using named parameters, Mediawiki will automatically remove any leading or trailing whitespace from the target string. ]] function str.len( frame ) local new_args = str._getParameters( frame.args, {'s'} ) local s = new_args['s'] or '' return mw.ustring.len( s ) end --[[ sub This function returns a substring of the target string at specified indices. Usage: {{#invoke:String|sub|target_string|start_index|end_index}} OR {{#invoke:String|sub|s=target_string|i=start_index|j=end_index}} Parameters s: The string to return a subset of i: The first index of the substring to return, defaults to 1. j: The last index of the string to return, defaults to the last character. The first character of the string is assigned an index of 1. If either i or j is a negative value, it is interpreted the same as selecting a character by counting from the end of the string. Hence, a value of -1 is the same as selecting the last character of the string. If the requested indices are out of range for the given string, an error is reported. ]] function str.sub( frame ) local new_args = str._getParameters( frame.args, { 's', 'i', 'j' } ) local s = new_args['s'] or '' local i = tonumber( new_args['i'] ) or 1 local j = tonumber( new_args['j'] ) or -1 local len = mw.ustring.len( s ) -- Convert negatives for range checking if i < 0 then i = len + i + 1 end if j < 0 then j = len + j + 1 end if i > len or j > len or i < 1 or j < 1 then return str._error( 'String subset index out of range' ) end if j < i then return str._error( 'String subset indices out of order' ) end return mw.ustring.sub( s, i, j ) end --[[ This function implements that features of {{str sub old}} and is kept in order to maintain these older templates. ]] function str.sublength( frame ) local i = tonumber( frame.args.i ) or 0 local len = tonumber( frame.args.len ) return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) ) end --[[ _match This function returns a substring from the source string that matches a specified pattern. It is exported for use in other modules Usage: strmatch = require("Module:String")._match sresult = strmatch( s, pattern, start, match, plain, nomatch ) Parameters s: The string to search pattern: The pattern or string to find within the string start: The index within the source string to start the search. The first character of the string has index 1. Defaults to 1. match: In some cases it may be possible to make multiple matches on a single string. This specifies which match to return, where the first match is match= 1. If a negative number is specified then a match is returned counting from the last match. Hence match = -1 is the same as requesting the last match. Defaults to 1. plain: A flag indicating that the pattern should be understood as plain text. Defaults to false. nomatch: If no match is found, output the "nomatch" value rather than an error. For information on constructing Lua patterns, a form of [regular expression], see: * http://www.lua.org/manual/5.1/manual.html#5.4.1 * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns ]] -- This sub-routine is exported for use in other modules function str._match( s, pattern, start, match_index, plain_flag, nomatch ) if s == '' then return str._error( 'Target string is empty' ) end if pattern == '' then return str._error( 'Pattern string is empty' ) end start = tonumber(start) or 1 if math.abs(start) < 1 or math.abs(start) > mw.ustring.len( s ) then return str._error( 'Requested start is out of range' ) end if match_index == 0 then return str._error( 'Match index is out of range' ) end if plain_flag then pattern = str._escapePattern( pattern ) end local result if match_index == 1 then -- Find first match is simple case result = mw.ustring.match( s, pattern, start ) else if start > 1 then s = mw.ustring.sub( s, start ) end local iterator = mw.ustring.gmatch(s, pattern) if match_index > 0 then -- Forward search for w in iterator do match_index = match_index - 1 if match_index == 0 then result = w break end end else -- Reverse search local result_table = {} local count = 1 for w in iterator do result_table[count] = w count = count + 1 end result = result_table[ count + match_index ] end end if result == nil then if nomatch == nil then return str._error( 'Match not found' ) else return nomatch end else return result end end --[[ match This function returns a substring from the source string that matches a specified pattern. Usage: {{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}} OR {{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index |match=match_number|plain=plain_flag|nomatch=nomatch_output}} Parameters s: The string to search pattern: The pattern or string to find within the string start: The index within the source string to start the search. The first character of the string has index 1. Defaults to 1. match: In some cases it may be possible to make multiple matches on a single string. This specifies which match to return, where the first match is match= 1. If a negative number is specified then a match is returned counting from the last match. Hence match = -1 is the same as requesting the last match. Defaults to 1. plain: A flag indicating that the pattern should be understood as plain text. Defaults to false. nomatch: If no match is found, output the "nomatch" value rather than an error. If invoked using named parameters, Mediawiki will automatically remove any leading or trailing whitespace from each string. In some circumstances this is desirable, in other cases one may want to preserve the whitespace. If the match_number or start_index are out of range for the string being queried, then this function generates an error. An error is also generated if no match is found. If one adds the parameter ignore_errors=true, then the error will be suppressed and an empty string will be returned on any failure. For information on constructing Lua patterns, a form of [regular expression], see: * http://www.lua.org/manual/5.1/manual.html#5.4.1 * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns ]] -- This is the entry point for #invoke:String|match function str.match( frame ) local new_args = str._getParameters( frame.args, {'s', 'pattern', 'start', 'match', 'plain', 'nomatch'} ) local s = new_args['s'] or '' local start = tonumber( new_args['start'] ) or 1 local plain_flag = str._getBoolean( new_args['plain'] or false ) local pattern = new_args['pattern'] or '' local match_index = math.floor( tonumber(new_args['match']) or 1 ) local nomatch = new_args['nomatch'] return str._match( s, pattern, start, match_index, plain_flag, nomatch ) end --[[ pos This function returns a single character from the target string at position pos. Usage: {{#invoke:String|pos|target_string|index_value}} OR {{#invoke:String|pos|target=target_string|pos=index_value}} Parameters target: The string to search pos: The index for the character to return If invoked using named parameters, Mediawiki will automatically remove any leading or trailing whitespace from the target string. In some circumstances this is desirable, in other cases one may want to preserve the whitespace. The first character has an index value of 1. If one requests a negative value, this function will select a character by counting backwards from the end of the string. In other words pos = -1 is the same as asking for the last character. A requested value of zero, or a value greater than the length of the string returns an error. ]] function str.pos( frame ) local new_args = str._getParameters( frame.args, {'target', 'pos'} ) local target_str = new_args['target'] or '' local pos = tonumber( new_args['pos'] ) or 0 if pos == 0 or math.abs(pos) > mw.ustring.len( target_str ) then return str._error( 'String index out of range' ) end return mw.ustring.sub( target_str, pos, pos ) end --[[ str_find This function duplicates the behavior of {{str_find}}, including all of its quirks. This is provided in order to support existing templates, but is NOT RECOMMENDED for new code and templates. New code is recommended to use the "find" function instead. Returns the first index in "source" that is a match to "target". Indexing is 1-based, and the function returns -1 if the "target" string is not present in "source". Important Note: If the "target" string is empty / missing, this function returns a value of "1", which is generally unexpected behavior, and must be accounted for separatetly. ]] function str.str_find( frame ) local new_args = str._getParameters( frame.args, {'source', 'target'} ) local source_str = new_args['source'] or '' local target_str = new_args['target'] or '' if target_str == '' then return 1 end local start = mw.ustring.find( source_str, target_str, 1, true ) if start == nil then start = -1 end return start end --[[ find This function allows one to search for a target string or pattern within another string. Usage: {{#invoke:String|find|source_str|target_string|start_index|plain_flag}} OR {{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}} Parameters source: The string to search target: The string or pattern to find within source start: The index within the source string to start the search, defaults to 1 plain: Boolean flag indicating that target should be understood as plain text and not as a Lua style regular expression, defaults to true If invoked using named parameters, Mediawiki will automatically remove any leading or trailing whitespace from the parameter. In some circumstances this is desirable, in other cases one may want to preserve the whitespace. This function returns the first index >= "start" where "target" can be found within "source". Indices are 1-based. If "target" is not found, then this function returns 0. If either "source" or "target" are missing / empty, this function also returns 0. This function should be safe for UTF-8 strings. ]] function str.find( frame ) local new_args = str._getParameters( frame.args, {'source', 'target', 'start', 'plain' } ) local source_str = new_args['source'] or '' local pattern = new_args['target'] or '' local start_pos = tonumber(new_args['start']) or 1 local plain = new_args['plain'] or true if source_str == '' or pattern == '' then return 0 end plain = str._getBoolean( plain ) local start = mw.ustring.find( source_str, pattern, start_pos, plain ) if start == nil then start = 0 end return start end --[[ replace This function allows one to replace a target string or pattern within another string. Usage: {{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}} OR {{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string| count=replacement_count|plain=plain_flag}} Parameters source: The string to search pattern: The string or pattern to find within source replace: The replacement text count: The number of occurences to replace, defaults to all. plain: Boolean flag indicating that pattern should be understood as plain text and not as a Lua style regular expression, defaults to true ]] function str.replace( frame ) local new_args = str._getParameters( frame.args, {'source', 'pattern', 'replace', 'count', 'plain' } ) local source_str = new_args['source'] or '' local pattern = new_args['pattern'] or '' local replace = new_args['replace'] or '' local count = tonumber( new_args['count'] ) local plain = new_args['plain'] or true if source_str == '' or pattern == '' then return source_str end plain = str._getBoolean( plain ) if plain then pattern = str._escapePattern( pattern ) replace = mw.ustring.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences. end local result if count ~= nil then result = mw.ustring.gsub( source_str, pattern, replace, count ) else result = mw.ustring.gsub( source_str, pattern, replace ) end return result end --[[ simple function to pipe string.rep to templates. ]] function str.rep( frame ) local repetitions = tonumber( frame.args[2] ) if not repetitions then return str._error( 'function rep expects a number as second parameter, received "' .. ( frame.args[2] or '' ) .. '"' ) end return string.rep( frame.args[1] or '', repetitions ) end --[[ escapePattern This function escapes special characters from a Lua string pattern. See [1] for details on how patterns work. [1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns Usage: {{#invoke:String|escapePattern|pattern_string}} Parameters pattern_string: The pattern string to escape. ]] function str.escapePattern( frame ) local pattern_str = frame.args[1] if not pattern_str then return str._error( 'No pattern string specified' ) end local result = str._escapePattern( pattern_str ) return result end --[[ count This function counts the number of occurrences of one string in another. ]] function str.count(frame) local args = str._getParameters(frame.args, {'source', 'pattern', 'plain'}) local source = args.source or '' local pattern = args.pattern or '' local plain = str._getBoolean(args.plain or true) if plain then pattern = str._escapePattern(pattern) end local _, count = mw.ustring.gsub(source, pattern, '') return count end --[[ endswith This function determines whether a string ends with another string. ]] function str.endswith(frame) local args = str._getParameters(frame.args, {'source', 'pattern'}) local source = args.source or '' local pattern = args.pattern or '' if pattern == '' then -- All strings end with the empty string. return "yes" end if mw.ustring.sub(source, -mw.ustring.len(pattern), -1) == pattern then return "yes" else return "" end end --[[ join Join all non empty arguments together; the first argument is the separator. Usage: {{#invoke:String|join|sep|one|two|three}} ]] function str.join(frame) local args = {} local sep for _, v in ipairs( frame.args ) do if sep then if v ~= '' then table.insert(args, v) end else sep = v end end return table.concat( args, sep or '' ) end --[[ Helper function that populates the argument list given that user may need to use a mix of named and unnamed parameters. This is relevant because named parameters are not identical to unnamed parameters due to string trimming, and when dealing with strings we sometimes want to either preserve or remove that whitespace depending on the application. ]] function str._getParameters( frame_args, arg_list ) local new_args = {} local index = 1 local value for _, arg in ipairs( arg_list ) do value = frame_args[arg] if value == nil then value = frame_args[index] index = index + 1 end new_args[arg] = value end return new_args end --[[ Helper function to handle error messages. ]] function str._error( error_str ) local frame = mw.getCurrentFrame() local error_category = frame.args.error_category or 'Errors reported by Module String' local ignore_errors = frame.args.ignore_errors or false local no_category = frame.args.no_category or false if str._getBoolean(ignore_errors) then return '' end local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>' if error_category ~= '' and not str._getBoolean( no_category ) then error_str = '[[Category:' .. error_category .. ']]' .. error_str end return error_str end --[[ Helper Function to interpret boolean strings ]] function str._getBoolean( boolean_str ) local boolean_value if type( boolean_str ) == 'string' then boolean_str = boolean_str:lower() if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0' or boolean_str == '' then boolean_value = false else boolean_value = true end elseif type( boolean_str ) == 'boolean' then boolean_value = boolean_str else error( 'No boolean value found' ) end return boolean_value end --[[ Helper function that escapes all pattern characters so that they will be treated as plain text. ]] function str._escapePattern( pattern_str ) return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ) end return str 2ad0905c56ef4955950b75a8f00974fe82aed5e4 Template:Template other 10 33 65 64 2024-04-03T17:30:55Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Template_other]] wikitext text/x-wiki {{#switch: <!--If no or empty "demospace" parameter then detect namespace--> {{#if:{{{demospace|}}} | {{lc: {{{demospace}}} }} <!--Use lower case "demospace"--> | {{#ifeq:{{NAMESPACE}}|{{ns:Template}} | template | other }} }} | template = {{{1|}}} | other | #default = {{{2|}}} }}<!--End switch--><noinclude> {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 06fb13d264df967b5232141067eb7d2b67372d76 Module:Effective protection expiry 828 34 67 66 2024-04-03T17:30:56Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Effective_protection_expiry]] Scribunto text/plain local p = {} -- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known. -- If no title is specified, the title of the page being displayed is used. function p._main(action, pagename) local title if type(pagename) == 'table' and pagename.prefixedText then title = pagename elseif pagename then title = mw.title.new(pagename) else title = mw.title.getCurrentTitle() end pagename = title.prefixedText if action == 'autoreview' then local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title) return stabilitySettings and stabilitySettings.expiry or 'unknown' elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 ) end local rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename) if rawExpiry == 'infinity' then return 'infinity' elseif rawExpiry == '' then return 'unknown' else local year, month, day, hour, minute, second = rawExpiry:match( '^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$' ) if year then return string.format( '%s-%s-%sT%s:%s:%s', year, month, day, hour, minute, second ) else error('internal error in Module:Effective protection expiry; malformed expiry timestamp') end end end setmetatable(p, { __index = function(t, k) return function(frame) return t._main(k, frame.args[1]) end end }) return p 9a8c58dc2667232ed08a9b206a5d89ca8150312b Module:Effective protection level 828 35 69 68 2024-04-03T17:30:56Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Effective_protection_level]] Scribunto text/plain local p = {} -- Returns the permission required to perform a given action on a given title. -- If no title is specified, the title of the page being displayed is used. function p._main(action, pagename) local title if type(pagename) == 'table' and pagename.prefixedText then title = pagename elseif pagename then title = mw.title.new(pagename) else title = mw.title.getCurrentTitle() end pagename = title.prefixedText if action == 'autoreview' then local level = mw.ext.FlaggedRevs.getStabilitySettings(title) level = level and level.autoreview if level == 'review' then return 'reviewer' elseif level ~= '' then return level else return nil -- not '*'. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not '', as that would mean PC-protected but nobody can review end elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then error( 'First parameter must be one of edit, move, create, upload, undelete, autoreview', 2 ) end if title.namespace == 8 then -- MediaWiki namespace if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page return 'interfaceadmin' else -- any non-JS/CSS MediaWiki page return 'sysop' end elseif title.namespace == 2 and title.isSubpage then if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page return 'interfaceadmin' elseif title.contentModel == 'json' then -- user JSON page return 'sysop' end end if action == 'undelete' then return 'sysop' end local level = title.protectionLevels[action] and title.protectionLevels[action][1] if level == 'sysop' or level == 'editprotected' then return 'sysop' elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page return 'sysop' elseif level == 'templateeditor' then return 'templateeditor' elseif action == 'move' then local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move. if blacklistentry and not blacklistentry.params.autoconfirmed then return 'templateeditor' elseif title.namespace == 6 then return 'filemover' elseif level == 'extendedconfirmed' then return 'extendedconfirmed' else return 'autoconfirmed' end end local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename) if blacklistentry then if not blacklistentry.params.autoconfirmed then return 'templateeditor' elseif level == 'extendedconfirmed' then return 'extendedconfirmed' else return 'autoconfirmed' end elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason return 'autoconfirmed' elseif level then return level elseif action == 'upload' then return 'autoconfirmed' elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts if title.namespace == 0 then return 'autoconfirmed' -- Per [[WP:ACPERM]], you need to be autoconfirmed to create pages in mainspace end return 'user' else return '*' end end setmetatable(p, { __index = function(t, k) return function(frame) return t._main(k, frame.args[1]) end end }) return p b6cb1e5589ec6575118f60841644cd65defa7174 Module:File link 828 36 71 70 2024-04-03T17:30:56Z Nulcow 2 1 revision imported from [[:wikipedia:Module:File_link]] Scribunto text/plain -- This module provides a library for formatting file wikilinks. local yesno = require('Module:Yesno') local checkType = require('libraryUtil').checkType local p = {} function p._main(args) checkType('_main', 1, args, 'table') -- This is basically libraryUtil.checkTypeForNamedArg, but we are rolling our -- own function to get the right error level. local function checkArg(key, val, level) if type(val) ~= 'string' then error(string.format( "type error in '%s' parameter of '_main' (expected string, got %s)", key, type(val) ), level) end end local ret = {} -- Adds a positional parameter to the buffer. local function addPositional(key) local val = args[key] if not val then return nil end checkArg(key, val, 4) ret[#ret + 1] = val end -- Adds a named parameter to the buffer. We assume that the parameter name -- is the same as the argument key. local function addNamed(key) local val = args[key] if not val then return nil end checkArg(key, val, 4) ret[#ret + 1] = key .. '=' .. val end -- Filename checkArg('file', args.file, 3) ret[#ret + 1] = 'File:' .. args.file -- Format if args.format then checkArg('format', args.format) if args.formatfile then checkArg('formatfile', args.formatfile) ret[#ret + 1] = args.format .. '=' .. args.formatfile else ret[#ret + 1] = args.format end end -- Border if yesno(args.border) then ret[#ret + 1] = 'border' end addPositional('location') addPositional('alignment') addPositional('size') addNamed('upright') addNamed('link') addNamed('alt') addNamed('page') addNamed('class') addNamed('lang') addNamed('start') addNamed('end') addNamed('thumbtime') addPositional('caption') return string.format('[[%s]]', table.concat(ret, '|')) end function p.main(frame) local origArgs = require('Module:Arguments').getArgs(frame, { wrappers = 'Template:File link' }) if not origArgs.file then error("'file' parameter missing from [[Template:File link]]", 0) end -- Copy the arguments that were passed to a new table to avoid looking up -- every possible parameter in the frame object. local args = {} for k, v in pairs(origArgs) do -- Make _BLANK a special argument to add a blank parameter. For use in -- conditional templates etc. it is useful for blank arguments to be -- ignored, but we still need a way to specify them so that we can do -- things like [[File:Example.png|link=]]. if v == '_BLANK' then v = '' end args[k] = v end return p._main(args) end return p 66925f088d11530f2482f04181a3baaaa0ad3d0c Module:Navbar 828 37 73 72 2024-04-03T17:30:57Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Navbar]] Scribunto text/plain local p = {} local cfg = mw.loadData('Module:Navbar/configuration') local function get_title_arg(is_collapsible, template) local title_arg = 1 if is_collapsible then title_arg = 2 end if template then title_arg = 'template' end return title_arg end local function choose_links(template, args) -- The show table indicates the default displayed items. -- view, talk, edit, hist, move, watch -- TODO: Move to configuration. local show = {true, true, true, false, false, false} if template then show[2] = false show[3] = false local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6, talk = 2, edit = 3, hist = 4, move = 5, watch = 6} -- TODO: Consider removing TableTools dependency. for _, v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do local num = index[v] if num then show[num] = true end end end local remove_edit_link = args.noedit if remove_edit_link then show[3] = false end return show end local function add_link(link_description, ul, is_mini, font_style) local l if link_description.url then l = {'[', '', ']'} else l = {'[[', '|', ']]'} end ul:tag('li') :addClass('nv-' .. link_description.full) :wikitext(l[1] .. link_description.link .. l[2]) :tag(is_mini and 'abbr' or 'span') :attr('title', link_description.html_title) :cssText(font_style) :wikitext(is_mini and link_description.mini or link_description.full) :done() :wikitext(l[3]) :done() end local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style) local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace) if not title then error(cfg.invalid_title .. title_text) end local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or '' -- TODO: Get link_descriptions and show into the configuration module. -- link_descriptions should be easier... local link_descriptions = { { ['mini'] = 'v', ['full'] = 'view', ['html_title'] = 'View this template', ['link'] = title.fullText, ['url'] = false }, { ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template', ['link'] = talkpage, ['url'] = false }, { ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template', ['link'] = 'Special:EditPage/' .. title.fullText, ['url'] = false }, { ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template', ['link'] = 'Special:PageHistory/' .. title.fullText, ['url'] = false }, { ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template', ['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true }, { ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template', ['link'] = title:fullUrl('action=watch'), ['url'] = true } } local ul = mw.html.create('ul') if has_brackets then ul:addClass(cfg.classes.brackets) :cssText(font_style) end for i, _ in ipairs(displayed_links) do if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end end return ul:done() end function p._navbar(args) -- TODO: We probably don't need both fontstyle and fontcolor... local font_style = args.fontstyle local font_color = args.fontcolor local is_collapsible = args.collapsible local is_mini = args.mini local is_plain = args.plain local collapsible_class = nil if is_collapsible then collapsible_class = cfg.classes.collapsible if not is_plain then is_mini = 1 end if font_color then font_style = (font_style or '') .. '; color: ' .. font_color .. ';' end end local navbar_style = args.style local div = mw.html.create():tag('div') div :addClass(cfg.classes.navbar) :addClass(cfg.classes.plainlinks) :addClass(cfg.classes.horizontal_list) :addClass(collapsible_class) -- we made the determination earlier :cssText(navbar_style) if is_mini then div:addClass(cfg.classes.mini) end local box_text = (args.text or cfg.box_text) .. ' ' -- the concatenated space guarantees the box text is separated if not (is_mini or is_plain) then div :tag('span') :addClass(cfg.classes.box_text) :cssText(font_style) :wikitext(box_text) end local template = args.template local displayed_links = choose_links(template, args) local has_brackets = args.brackets local title_arg = get_title_arg(is_collapsible, template) local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle()) local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style) div:node(list) if is_collapsible then local title_text_class if is_mini then title_text_class = cfg.classes.collapsible_title_mini else title_text_class = cfg.classes.collapsible_title_full end div:done() :tag('div') :addClass(title_text_class) :cssText(font_style) :wikitext(args[1]) end local frame = mw.getCurrentFrame() -- hlist -> navbar is best-effort to preserve old Common.css ordering. return frame:extensionTag{ name = 'templatestyles', args = { src = cfg.hlist_templatestyles } } .. frame:extensionTag{ name = 'templatestyles', args = { src = cfg.templatestyles } } .. tostring(div:done()) end function p.navbar(frame) return p._navbar(require('Module:Arguments').getArgs(frame)) end return p 047f307758c878eb3e99ed1768cc40920a6ec5fa Module:Navbar/configuration 828 38 75 74 2024-04-03T17:30:57Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Navbar/configuration]] Scribunto text/plain return { ['templatestyles'] = 'Module:Navbar/styles.css', ['hlist_templatestyles'] = 'Hlist/styles.css', ['box_text'] = 'This box: ', -- default text box when not plain or mini ['title_namespace'] = 'Template', -- namespace to default to for title ['invalid_title'] = 'Invalid title ', ['classes'] = { -- set a line to nil if you don't want it ['navbar'] = 'navbar', ['plainlinks'] = 'plainlinks', -- plainlinks ['horizontal_list'] = 'hlist', -- horizontal list class ['mini'] = 'navbar-mini', -- class indicating small links in the navbar ['this_box'] = 'navbar-boxtext', ['brackets'] = 'navbar-brackets', -- 'collapsible' is the key for a class to indicate the navbar is -- setting up the collapsible element in addition to the normal -- navbar. ['collapsible'] = 'navbar-collapse', ['collapsible_title_mini'] = 'navbar-ct-mini', ['collapsible_title_full'] = 'navbar-ct-full' } } b007c336b17ec4bcd4d5a9dca9f8cba301662b55 Module:Navbar/styles.css 828 39 77 76 2024-04-03T17:30:58Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Navbar/styles.css]] sanitized-css text/css /* {{pp|small=yes}} */ .navbar { display: inline; font-size: 88%; font-weight: normal; } .navbar-collapse { float: left; text-align: left; } .navbar-boxtext { word-spacing: 0; } .navbar ul { display: inline-block; white-space: nowrap; line-height: inherit; } .navbar-brackets::before { margin-right: -0.125em; content: '[ '; } .navbar-brackets::after { margin-left: -0.125em; content: ' ]'; } .navbar li { word-spacing: -0.125em; } .navbar a > span, .navbar a > abbr { text-decoration: inherit; } .navbar-mini abbr { font-variant: small-caps; border-bottom: none; text-decoration: none; cursor: inherit; } .navbar-ct-full { font-size: 114%; margin: 0 7em; } .navbar-ct-mini { font-size: 114%; margin: 0 4em; } 9d4056f949b4f0b159e3d40dfb1a5f01e72f9571 Module:Protection banner 828 40 79 78 2024-04-03T17:30:58Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Protection_banner]] Scribunto text/plain -- This module implements {{pp-meta}} and its daughter templates such as -- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}. -- Initialise necessary modules. require('strict') local makeFileLink = require('Module:File link')._main local effectiveProtectionLevel = require('Module:Effective protection level')._main local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main local yesno = require('Module:Yesno') -- Lazily initialise modules and objects we don't always need. local getArgs, makeMessageBox, lang -- Set constants. local CONFIG_MODULE = 'Module:Protection banner/config' -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function makeCategoryLink(cat, sort) if cat then return string.format( '[[%s:%s|%s]]', mw.site.namespaces[14].name, cat, sort ) end end -- Validation function for the expiry and the protection date local function validateDate(dateString, dateType) if not lang then lang = mw.language.getContentLanguage() end local success, result = pcall(lang.formatDate, lang, 'U', dateString) if success then result = tonumber(result) if result then return result end end error(string.format( 'invalid %s: %s', dateType, tostring(dateString) ), 4) end local function makeFullUrl(page, query, display) return string.format( '[%s %s]', tostring(mw.uri.fullUrl(page, query)), display ) end -- Given a directed graph formatted as node -> table of direct successors, -- get a table of all nodes reachable from a given node (though always -- including the given node). local function getReachableNodes(graph, start) local toWalk, retval = {[start] = true}, {} while true do -- Can't use pairs() since we're adding and removing things as we're iterating local k = next(toWalk) -- This always gets the "first" key if k == nil then return retval end toWalk[k] = nil retval[k] = true for _,v in ipairs(graph[k]) do if not retval[v] then toWalk[v] = true end end end end -------------------------------------------------------------------------------- -- Protection class -------------------------------------------------------------------------------- local Protection = {} Protection.__index = Protection Protection.supportedActions = { edit = true, move = true, autoreview = true, upload = true } Protection.bannerConfigFields = { 'text', 'explanation', 'tooltip', 'alt', 'link', 'image' } function Protection.new(args, cfg, title) local obj = {} obj._cfg = cfg obj.title = title or mw.title.getCurrentTitle() -- Set action if not args.action then obj.action = 'edit' elseif Protection.supportedActions[args.action] then obj.action = args.action else error(string.format( 'invalid action: %s', tostring(args.action) ), 3) end -- Set level obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title) if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then -- Users need to be autoconfirmed to move pages anyway, so treat -- semi-move-protected pages as unprotected. obj.level = '*' end -- Set expiry local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title) if effectiveExpiry == 'infinity' then obj.expiry = 'indef' elseif effectiveExpiry ~= 'unknown' then obj.expiry = validateDate(effectiveExpiry, 'expiry date') end -- Set reason if args[1] then obj.reason = mw.ustring.lower(args[1]) if obj.reason:find('|') then error('reasons cannot contain the pipe character ("|")', 3) end end -- Set protection date if args.date then obj.protectionDate = validateDate(args.date, 'protection date') end -- Set banner config do obj.bannerConfig = {} local configTables = {} if cfg.banners[obj.action] then configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason] end if cfg.defaultBanners[obj.action] then configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level] configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default end configTables[#configTables + 1] = cfg.masterBanner for i, field in ipairs(Protection.bannerConfigFields) do for j, t in ipairs(configTables) do if t[field] then obj.bannerConfig[field] = t[field] break end end end end return setmetatable(obj, Protection) end function Protection:isUserScript() -- Whether the page is a user JavaScript or CSS page. local title = self.title return title.namespace == 2 and ( title.contentModel == 'javascript' or title.contentModel == 'css' ) end function Protection:isProtected() return self.level ~= '*' end function Protection:shouldShowLock() -- Whether we should output a banner/padlock return self:isProtected() and not self:isUserScript() end -- Whether this page needs a protection category. Protection.shouldHaveProtectionCategory = Protection.shouldShowLock function Protection:isTemporary() return type(self.expiry) == 'number' end function Protection:makeProtectionCategory() if not self:shouldHaveProtectionCategory() then return '' end local cfg = self._cfg local title = self.title -- Get the expiry key fragment. local expiryFragment if self.expiry == 'indef' then expiryFragment = self.expiry elseif type(self.expiry) == 'number' then expiryFragment = 'temp' end -- Get the namespace key fragment. local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace] if not namespaceFragment and title.namespace % 2 == 1 then namespaceFragment = 'talk' end -- Define the order that key fragments are tested in. This is done with an -- array of tables containing the value to be tested, along with its -- position in the cfg.protectionCategories table. local order = { {val = expiryFragment, keypos = 1}, {val = namespaceFragment, keypos = 2}, {val = self.reason, keypos = 3}, {val = self.level, keypos = 4}, {val = self.action, keypos = 5} } --[[ -- The old protection templates used an ad-hoc protection category system, -- with some templates prioritising namespaces in their categories, and -- others prioritising the protection reason. To emulate this in this module -- we use the config table cfg.reasonsWithNamespacePriority to set the -- reasons for which namespaces have priority over protection reason. -- If we are dealing with one of those reasons, move the namespace table to -- the end of the order table, i.e. give it highest priority. If not, the -- reason should have highest priority, so move that to the end of the table -- instead. --]] table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3)) --[[ -- Define the attempt order. Inactive subtables (subtables with nil "value" -- fields) are moved to the end, where they will later be given the key -- "all". This is to cut down on the number of table lookups in -- cfg.protectionCategories, which grows exponentially with the number of -- non-nil keys. We keep track of the number of active subtables with the -- noActive parameter. --]] local noActive, attemptOrder do local active, inactive = {}, {} for i, t in ipairs(order) do if t.val then active[#active + 1] = t else inactive[#inactive + 1] = t end end noActive = #active attemptOrder = active for i, t in ipairs(inactive) do attemptOrder[#attemptOrder + 1] = t end end --[[ -- Check increasingly generic key combinations until we find a match. If a -- specific category exists for the combination of key fragments we are -- given, that match will be found first. If not, we keep trying different -- key fragment combinations until we match using the key -- "all-all-all-all-all". -- -- To generate the keys, we index the key subtables using a binary matrix -- with indexes i and j. j is only calculated up to the number of active -- subtables. For example, if there were three active subtables, the matrix -- would look like this, with 0 corresponding to the key fragment "all", and -- 1 corresponding to other key fragments. -- -- j 1 2 3 -- i -- 1 1 1 1 -- 2 0 1 1 -- 3 1 0 1 -- 4 0 0 1 -- 5 1 1 0 -- 6 0 1 0 -- 7 1 0 0 -- 8 0 0 0 -- -- Values of j higher than the number of active subtables are set -- to the string "all". -- -- A key for cfg.protectionCategories is constructed for each value of i. -- The position of the value in the key is determined by the keypos field in -- each subtable. --]] local cats = cfg.protectionCategories for i = 1, 2^noActive do local key = {} for j, t in ipairs(attemptOrder) do if j > noActive then key[t.keypos] = 'all' else local quotient = i / 2 ^ (j - 1) quotient = math.ceil(quotient) if quotient % 2 == 1 then key[t.keypos] = t.val else key[t.keypos] = 'all' end end end key = table.concat(key, '|') local attempt = cats[key] if attempt then return makeCategoryLink(attempt, title.text) end end return '' end function Protection:isIncorrect() local expiry = self.expiry return not self:shouldHaveProtectionCategory() or type(expiry) == 'number' and expiry < os.time() end function Protection:isTemplateProtectedNonTemplate() local action, namespace = self.action, self.title.namespace return self.level == 'templateeditor' and ( (action ~= 'edit' and action ~= 'move') or (namespace ~= 10 and namespace ~= 828) ) end function Protection:makeCategoryLinks() local msg = self._cfg.msg local ret = {self:makeProtectionCategory()} if self:isIncorrect() then ret[#ret + 1] = makeCategoryLink( msg['tracking-category-incorrect'], self.title.text ) end if self:isTemplateProtectedNonTemplate() then ret[#ret + 1] = makeCategoryLink( msg['tracking-category-template'], self.title.text ) end return table.concat(ret) end -------------------------------------------------------------------------------- -- Blurb class -------------------------------------------------------------------------------- local Blurb = {} Blurb.__index = Blurb Blurb.bannerTextFields = { text = true, explanation = true, tooltip = true, alt = true, link = true } function Blurb.new(protectionObj, args, cfg) return setmetatable({ _cfg = cfg, _protectionObj = protectionObj, _args = args }, Blurb) end -- Private methods -- function Blurb:_formatDate(num) -- Formats a Unix timestamp into dd Month, YYYY format. lang = lang or mw.language.getContentLanguage() local success, date = pcall( lang.formatDate, lang, self._cfg.msg['expiry-date-format'] or 'j F Y', '@' .. tostring(num) ) if success then return date end end function Blurb:_getExpandedMessage(msgKey) return self:_substituteParameters(self._cfg.msg[msgKey]) end function Blurb:_substituteParameters(msg) if not self._params then local parameterFuncs = {} parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter parameterFuncs.EDITREQUEST = self._makeEditRequestParameter parameterFuncs.EXPIRY = self._makeExpiryParameter parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter parameterFuncs.IMAGELINK = self._makeImageLinkParameter parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter parameterFuncs.PAGETYPE = self._makePagetypeParameter parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter parameterFuncs.TALKPAGE = self._makeTalkPageParameter parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter parameterFuncs.VANDAL = self._makeVandalTemplateParameter self._params = setmetatable({}, { __index = function (t, k) local param if parameterFuncs[k] then param = parameterFuncs[k](self) end param = param or '' t[k] = param return param end }) end msg = msg:gsub('${(%u+)}', self._params) return msg end function Blurb:_makeCurrentVersionParameter() -- A link to the page history or the move log, depending on the kind of -- protection. local pagename = self._protectionObj.title.prefixedText if self._protectionObj.action == 'move' then -- We need the move log link. return makeFullUrl( 'Special:Log', {type = 'move', page = pagename}, self:_getExpandedMessage('current-version-move-display') ) else -- We need the history link. return makeFullUrl( pagename, {action = 'history'}, self:_getExpandedMessage('current-version-edit-display') ) end end function Blurb:_makeEditRequestParameter() local mEditRequest = require('Module:Submit an edit request') local action = self._protectionObj.action local level = self._protectionObj.level -- Get the edit request type. local requestType if action == 'edit' then if level == 'autoconfirmed' then requestType = 'semi' elseif level == 'extendedconfirmed' then requestType = 'extended' elseif level == 'templateeditor' then requestType = 'template' end end requestType = requestType or 'full' -- Get the display value. local display = self:_getExpandedMessage('edit-request-display') return mEditRequest._link{type = requestType, display = display} end function Blurb:_makeExpiryParameter() local expiry = self._protectionObj.expiry if type(expiry) == 'number' then return self:_formatDate(expiry) else return expiry end end function Blurb:_makeExplanationBlurbParameter() -- Cover special cases first. if self._protectionObj.title.namespace == 8 then -- MediaWiki namespace return self:_getExpandedMessage('explanation-blurb-nounprotect') end -- Get explanation blurb table keys local action = self._protectionObj.action local level = self._protectionObj.level local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject' -- Find the message in the explanation blurb table and substitute any -- parameters. local explanations = self._cfg.explanationBlurbs local msg if explanations[action][level] and explanations[action][level][talkKey] then msg = explanations[action][level][talkKey] elseif explanations[action][level] and explanations[action][level].default then msg = explanations[action][level].default elseif explanations[action].default and explanations[action].default[talkKey] then msg = explanations[action].default[talkKey] elseif explanations[action].default and explanations[action].default.default then msg = explanations[action].default.default else error(string.format( 'could not find explanation blurb for action "%s", level "%s" and talk key "%s"', action, level, talkKey ), 8) end return self:_substituteParameters(msg) end function Blurb:_makeImageLinkParameter() local imageLinks = self._cfg.imageLinks local action = self._protectionObj.action local level = self._protectionObj.level local msg if imageLinks[action][level] then msg = imageLinks[action][level] elseif imageLinks[action].default then msg = imageLinks[action].default else msg = imageLinks.edit.default end return self:_substituteParameters(msg) end function Blurb:_makeIntroBlurbParameter() if self._protectionObj:isTemporary() then return self:_getExpandedMessage('intro-blurb-expiry') else return self:_getExpandedMessage('intro-blurb-noexpiry') end end function Blurb:_makeIntroFragmentParameter() if self._protectionObj:isTemporary() then return self:_getExpandedMessage('intro-fragment-expiry') else return self:_getExpandedMessage('intro-fragment-noexpiry') end end function Blurb:_makePagetypeParameter() local pagetypes = self._cfg.pagetypes return pagetypes[self._protectionObj.title.namespace] or pagetypes.default or error('no default pagetype defined', 8) end function Blurb:_makeProtectionBlurbParameter() local protectionBlurbs = self._cfg.protectionBlurbs local action = self._protectionObj.action local level = self._protectionObj.level local msg if protectionBlurbs[action][level] then msg = protectionBlurbs[action][level] elseif protectionBlurbs[action].default then msg = protectionBlurbs[action].default elseif protectionBlurbs.edit.default then msg = protectionBlurbs.edit.default else error('no protection blurb defined for protectionBlurbs.edit.default', 8) end return self:_substituteParameters(msg) end function Blurb:_makeProtectionDateParameter() local protectionDate = self._protectionObj.protectionDate if type(protectionDate) == 'number' then return self:_formatDate(protectionDate) else return protectionDate end end function Blurb:_makeProtectionLevelParameter() local protectionLevels = self._cfg.protectionLevels local action = self._protectionObj.action local level = self._protectionObj.level local msg if protectionLevels[action][level] then msg = protectionLevels[action][level] elseif protectionLevels[action].default then msg = protectionLevels[action].default elseif protectionLevels.edit.default then msg = protectionLevels.edit.default else error('no protection level defined for protectionLevels.edit.default', 8) end return self:_substituteParameters(msg) end function Blurb:_makeProtectionLogParameter() local pagename = self._protectionObj.title.prefixedText if self._protectionObj.action == 'autoreview' then -- We need the pending changes log. return makeFullUrl( 'Special:Log', {type = 'stable', page = pagename}, self:_getExpandedMessage('pc-log-display') ) else -- We need the protection log. return makeFullUrl( 'Special:Log', {type = 'protect', page = pagename}, self:_getExpandedMessage('protection-log-display') ) end end function Blurb:_makeTalkPageParameter() return string.format( '[[%s:%s#%s|%s]]', mw.site.namespaces[self._protectionObj.title.namespace].talk.name, self._protectionObj.title.text, self._args.section or 'top', self:_getExpandedMessage('talk-page-link-display') ) end function Blurb:_makeTooltipBlurbParameter() if self._protectionObj:isTemporary() then return self:_getExpandedMessage('tooltip-blurb-expiry') else return self:_getExpandedMessage('tooltip-blurb-noexpiry') end end function Blurb:_makeTooltipFragmentParameter() if self._protectionObj:isTemporary() then return self:_getExpandedMessage('tooltip-fragment-expiry') else return self:_getExpandedMessage('tooltip-fragment-noexpiry') end end function Blurb:_makeVandalTemplateParameter() return mw.getCurrentFrame():expandTemplate{ title="vandal-m", args={self._args.user or self._protectionObj.title.baseText} } end -- Public methods -- function Blurb:makeBannerText(key) -- Validate input. if not key or not Blurb.bannerTextFields[key] then error(string.format( '"%s" is not a valid banner config field', tostring(key) ), 2) end -- Generate the text. local msg = self._protectionObj.bannerConfig[key] if type(msg) == 'string' then return self:_substituteParameters(msg) elseif type(msg) == 'function' then msg = msg(self._protectionObj, self._args) if type(msg) ~= 'string' then error(string.format( 'bad output from banner config function with key "%s"' .. ' (expected string, got %s)', tostring(key), type(msg) ), 4) end return self:_substituteParameters(msg) end end -------------------------------------------------------------------------------- -- BannerTemplate class -------------------------------------------------------------------------------- local BannerTemplate = {} BannerTemplate.__index = BannerTemplate function BannerTemplate.new(protectionObj, cfg) local obj = {} obj._cfg = cfg -- Set the image filename. local imageFilename = protectionObj.bannerConfig.image if imageFilename then obj._imageFilename = imageFilename else -- If an image filename isn't specified explicitly in the banner config, -- generate it from the protection status and the namespace. local action = protectionObj.action local level = protectionObj.level local namespace = protectionObj.title.namespace local reason = protectionObj.reason -- Deal with special cases first. if ( namespace == 10 or namespace == 828 or reason and obj._cfg.indefImageReasons[reason] ) and action == 'edit' and level == 'sysop' and not protectionObj:isTemporary() then -- Fully protected modules and templates get the special red "indef" -- padlock. obj._imageFilename = obj._cfg.msg['image-filename-indef'] else -- Deal with regular protection types. local images = obj._cfg.images if images[action] then if images[action][level] then obj._imageFilename = images[action][level] elseif images[action].default then obj._imageFilename = images[action].default end end end end return setmetatable(obj, BannerTemplate) end function BannerTemplate:renderImage() local filename = self._imageFilename or self._cfg.msg['image-filename-default'] or 'Transparent.gif' return makeFileLink{ file = filename, size = (self.imageWidth or 20) .. 'px', alt = self._imageAlt, link = self._imageLink, caption = self.imageCaption } end -------------------------------------------------------------------------------- -- Banner class -------------------------------------------------------------------------------- local Banner = setmetatable({}, BannerTemplate) Banner.__index = Banner function Banner.new(protectionObj, blurbObj, cfg) local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb. obj.imageWidth = 40 obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip. obj._reasonText = blurbObj:makeBannerText('text') obj._explanationText = blurbObj:makeBannerText('explanation') obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing. return setmetatable(obj, Banner) end function Banner:__tostring() -- Renders the banner. makeMessageBox = makeMessageBox or require('Module:Message box').main local reasonText = self._reasonText or error('no reason text set', 2) local explanationText = self._explanationText local mbargs = { page = self._page, type = 'protection', image = self:renderImage(), text = string.format( "'''%s'''%s", reasonText, explanationText and '<br />' .. explanationText or '' ) } return makeMessageBox('mbox', mbargs) end -------------------------------------------------------------------------------- -- Padlock class -------------------------------------------------------------------------------- local Padlock = setmetatable({}, BannerTemplate) Padlock.__index = Padlock function Padlock.new(protectionObj, blurbObj, cfg) local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb. obj.imageWidth = 20 obj.imageCaption = blurbObj:makeBannerText('tooltip') obj._imageAlt = blurbObj:makeBannerText('alt') obj._imageLink = blurbObj:makeBannerText('link') obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action] or cfg.padlockIndicatorNames.default or 'pp-default' return setmetatable(obj, Padlock) end function Padlock:__tostring() local frame = mw.getCurrentFrame() -- The nowiki tag helps prevent whitespace at the top of articles. return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{ name = 'indicator', args = {name = self._indicatorName}, content = self:renderImage() } end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- This is used for testing purposes. return { Protection = Protection, Blurb = Blurb, BannerTemplate = BannerTemplate, Banner = Banner, Padlock = Padlock, } end function p._main(args, cfg, title) args = args or {} cfg = cfg or require(CONFIG_MODULE) local protectionObj = Protection.new(args, cfg, title) local ret = {} -- If a page's edit protection is equally or more restrictive than its -- protection from some other action, then don't bother displaying anything -- for the other action (except categories). if not yesno(args.catonly) and (protectionObj.action == 'edit' or args.demolevel or not getReachableNodes( cfg.hierarchy, protectionObj.level )[effectiveProtectionLevel('edit', protectionObj.title)]) then -- Initialise the blurb object local blurbObj = Blurb.new(protectionObj, args, cfg) -- Render the banner if protectionObj:shouldShowLock() then ret[#ret + 1] = tostring( (yesno(args.small) and Padlock or Banner) .new(protectionObj, blurbObj, cfg) ) end end -- Render the categories if yesno(args.category) ~= false then ret[#ret + 1] = protectionObj:makeCategoryLinks() end return table.concat(ret) end function p.main(frame, cfg) cfg = cfg or require(CONFIG_MODULE) -- Find default args, if any. local parent = frame.getParent and frame:getParent() local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')] -- Find user args, and use the parent frame if we are being called from a -- wrapper template. getArgs = getArgs or require('Module:Arguments').getArgs local userArgs = getArgs(frame, { parentOnly = defaultArgs, frameOnly = not defaultArgs }) -- Build the args table. User-specified args overwrite default args. local args = {} for k, v in pairs(defaultArgs or {}) do args[k] = v end for k, v in pairs(userArgs) do args[k] = v end return p._main(args, cfg) end return p 894f0884d4c2da1ce19d385b96f59af654b0946a Module:Protection banner/config 828 41 81 80 2024-04-03T17:30:58Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Protection_banner/config]] Scribunto text/plain -- This module provides configuration data for [[Module:Protection banner]]. return { -------------------------------------------------------------------------------- -- -- BANNER DATA -- -------------------------------------------------------------------------------- --[[ -- Banner data consists of six fields: -- * text - the main protection text that appears at the top of protection -- banners. -- * explanation - the text that appears below the main protection text, used -- to explain the details of the protection. -- * tooltip - the tooltip text you see when you move the mouse over a small -- padlock icon. -- * link - the page that the small padlock icon links to. -- * alt - the alt text for the small padlock icon. This is also used as tooltip -- text for the large protection banners. -- * image - the padlock image used in both protection banners and small padlock -- icons. -- -- The module checks in three separate tables to find a value for each field. -- First it checks the banners table, which has values specific to the reason -- for the page being protected. Then the module checks the defaultBanners -- table, which has values specific to each protection level. Finally, the -- module checks the masterBanner table, which holds data for protection -- templates to use if no data has been found in the previous two tables. -- -- The values in the banner data can take parameters. These are specified -- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name -- enclosed in curly braces). -- -- Available parameters: -- -- ${CURRENTVERSION} - a link to the page history or the move log, with the -- display message "current-version-edit-display" or -- "current-version-move-display". -- -- ${EDITREQUEST} - a link to create an edit request for the current page. -- -- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes -- on the talk page; you may submit a request to ask an administrator to make -- an edit if it is minor or supported by consensus." -- -- ${IMAGELINK} - a link to set the image to, depending on the protection -- action and protection level. -- -- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry -- is set. E.g. "Editing of this page by new or unregistered users is currently -- disabled until dd Month YYYY." -- -- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation -- so that it can be used in run-on sentences. -- -- ${PAGETYPE} - the type of the page, e.g. "article" or "template". -- Defined in the cfg.pagetypes table. -- -- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g. -- "Editing of this page by new or unregistered users is currently disabled" -- -- ${PROTECTIONDATE} - the protection date, if it has been supplied to the -- template. -- -- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or -- "semi-protected". -- -- ${PROTECTIONLOG} - a link to the protection log or the pending changes log, -- depending on the protection action. -- -- ${TALKPAGE} - a link to the talk page. If a section is specified, links -- straight to that talk page section. -- -- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to -- create a blurb like "This template is semi-protected", or "This article is -- move-protected until DD Month YYYY". -- -- ${VANDAL} - links for the specified username (or the root page name) -- using Module:Vandal-m. -- -- Functions -- -- For advanced users, it is possible to use Lua functions instead of strings -- in the banner config tables. Using functions gives flexibility that is not -- possible just by using parameters. Functions take two arguments, the -- protection object and the template arguments, and they must output a string. -- -- For example: -- -- text = function (protectionObj, args) -- if protectionObj.level == 'autoconfirmed' then -- return 'foo' -- else -- return 'bar' -- end -- end -- -- Some protection object properties and methods that may be useful: -- protectionObj.action - the protection action -- protectionObj.level - the protection level -- protectionObj.reason - the protection reason -- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set -- to indefinite, and the protection time in unix time if temporary. -- protectionObj.protectionDate - the protection date in unix time, or nil if -- unspecified. -- protectionObj.bannerConfig - the banner config found by the module. Beware -- of editing the config field used by the function, as it could create an -- infinite loop. -- protectionObj:isProtected - returns a boolean showing whether the page is -- protected. -- protectionObj:isTemporary - returns a boolean showing whether the expiry is -- temporary. -- protectionObj:isIncorrect - returns a boolean showing whether the protection -- template is incorrect. --]] -- The master banner data, used if no values have been found in banners or -- defaultBanners. masterBanner = { text = '${INTROBLURB}', explanation = '${EXPLANATIONBLURB}', tooltip = '${TOOLTIPBLURB}', link = '${IMAGELINK}', alt = 'Page ${PROTECTIONLEVEL}' }, -- The default banner data. This holds banner data for different protection -- levels. -- *required* - this table needs edit, move, autoreview and upload subtables. defaultBanners = { edit = {}, move = {}, autoreview = { default = { alt = 'Page protected with pending changes', tooltip = 'All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users', image = 'Pending-protection-shackle.svg' } }, upload = {} }, -- The banner data. This holds banner data for different protection reasons. -- In fact, the reasons specified in this table control which reasons are -- valid inputs to the first positional parameter. -- -- There is also a non-standard "description" field that can be used for items -- in this table. This is a description of the protection reason for use in the -- module documentation. -- -- *required* - this table needs edit, move, autoreview and upload subtables. banners = { edit = { blp = { description = 'For pages protected to promote compliance with the' .. ' [[Wikipedia:Biographies of living persons' .. '|biographies of living persons]] policy', text = '${INTROFRAGMENT} to promote compliance with' .. ' [[Wikipedia:Biographies of living persons' .. "|Wikipedia's&nbsp;policy on&nbsp;the&nbsp;biographies" .. ' of&nbsp;living&nbsp;people]].', tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on' .. ' biographies of living persons', }, dmca = { description = 'For pages protected by the Wikimedia Foundation' .. ' due to [[Digital Millennium Copyright Act]] takedown requests', explanation = function (protectionObj, args) local ret = 'Pursuant to a rights owner notice under the Digital' .. ' Millennium Copyright Act (DMCA) regarding some content' .. ' in this article, the Wikimedia Foundation acted under' .. ' applicable law and took down and restricted the content' .. ' in question.' if args.notice then ret = ret .. ' A copy of the received notice can be found here: ' .. args.notice .. '.' end ret = ret .. ' For more information, including websites discussing' .. ' how to file a counter-notice, please see' .. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}." .. "'''Do not remove this template from the article until the" .. " restrictions are withdrawn'''." return ret end, image = 'Office-protection-shackle.svg', }, dispute = { description = 'For pages protected due to editing disputes', text = function (protectionObj, args) -- Find the value of "disputes". local display = 'disputes' local disputes if args.section then disputes = string.format( '[[%s:%s#%s|%s]]', mw.site.namespaces[protectionObj.title.namespace].talk.name, protectionObj.title.text, args.section, display ) else disputes = display end -- Make the blurb, depending on the expiry. local msg if type(protectionObj.expiry) == 'number' then msg = '${INTROFRAGMENT} or until editing %s have been resolved.' else msg = '${INTROFRAGMENT} until editing %s have been resolved.' end return string.format(msg, disputes) end, explanation = "This protection is '''not''' an endorsement of the" .. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}', tooltip = '${TOOLTIPFRAGMENT} due to editing disputes', }, ecp = { description = 'For articles in topic areas authorized by' .. ' [[Wikipedia:Arbitration Committee|ArbCom]] or' .. ' meets the criteria for community use', tooltip = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}', alt = 'Extended-protected ${PAGETYPE}', }, mainpage = { description = 'For pages protected for being displayed on the [[Main Page]]', text = 'This file is currently' .. ' [[Wikipedia:This page is protected|protected]] from' .. ' editing because it is currently or will soon be displayed' .. ' on the [[Main Page]].', explanation = 'Images on the Main Page are protected due to their high' .. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.' .. '<br /><span style="font-size:90%;">' .. "'''Administrators:''' Once this image is definitely off the Main Page," .. ' please unprotect this file, or reduce to semi-protection,' .. ' as appropriate.</span>', }, office = { description = 'For pages protected by the Wikimedia Foundation', text = function (protectionObj, args) local ret = 'This ${PAGETYPE} is currently under the' .. ' scrutiny of the' .. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]' .. ' and is protected.' if protectionObj.protectionDate then ret = ret .. ' It has been protected since ${PROTECTIONDATE}.' end return ret end, explanation = "If you can edit this page, please discuss all changes and" .. " additions on the ${TALKPAGE} first. '''Do not remove protection from this" .. " page unless you are authorized by the Wikimedia Foundation to do" .. " so.'''", image = 'Office-protection-shackle.svg', }, reset = { description = 'For pages protected by the Wikimedia Foundation and' .. ' "reset" to a bare-bones version', text = 'This ${PAGETYPE} is currently under the' .. ' scrutiny of the' .. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]' .. ' and is protected.', explanation = function (protectionObj, args) local ret = '' if protectionObj.protectionDate then ret = ret .. 'On ${PROTECTIONDATE} this ${PAGETYPE} was' else ret = ret .. 'This ${PAGETYPE} has been' end ret = ret .. ' reduced to a' .. ' simplified, "bare bones" version so that it may be completely' .. ' rewritten to ensure it meets the policies of' .. ' [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].' .. ' Standard Wikipedia policies will apply to its rewriting—which' .. ' will eventually be open to all editors—and will be strictly' .. ' enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while' .. ' it is being rebuilt.\n\n' .. 'Any insertion of material directly from' .. ' pre-protection revisions of the ${PAGETYPE} will be removed, as' .. ' will any material added to the ${PAGETYPE} that is not properly' .. ' sourced. The associated talk page(s) were also cleared on the' .. " same date.\n\n" .. "If you can edit this page, please discuss all changes and" .. " additions on the ${TALKPAGE} first. '''Do not override" .. " this action, and do not remove protection from this page," .. " unless you are authorized by the Wikimedia Foundation" .. " to do so. No editor may remove this notice.'''" return ret end, image = 'Office-protection-shackle.svg', }, sock = { description = 'For pages protected due to' .. ' [[Wikipedia:Sock puppetry|sock puppetry]]', text = '${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of' .. ' [[Wikipedia:Blocking policy|blocked]] or' .. ' [[Wikipedia:Banning policy|banned users]]' .. ' from editing it.', tooltip = '${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from' .. ' editing it', }, template = { description = 'For [[Wikipedia:High-risk templates|high-risk]]' .. ' templates and Lua modules', text = 'This is a permanently [[Help:Protection|protected]] ${PAGETYPE},' .. ' as it is [[Wikipedia:High-risk templates|high-risk]].', explanation = 'Please discuss any changes on the ${TALKPAGE}; you may' .. ' ${EDITREQUEST} to ask an' .. ' [[Wikipedia:Administrators|administrator]] or' .. ' [[Wikipedia:Template editor|template editor]] to make an edit if' .. ' it is [[Help:Minor edit#When to mark an edit as a minor edit' .. '|uncontroversial]] or supported by' .. ' [[Wikipedia:Consensus|consensus]]. You can also' .. ' [[Wikipedia:Requests for page protection|request]] that the page be' .. ' unprotected.', tooltip = 'This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}' .. ' to prevent vandalism', alt = 'Permanently protected ${PAGETYPE}', }, usertalk = { description = 'For pages protected against disruptive edits by a' .. ' particular user', text = '${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,' .. ' such as abusing the' .. ' &#123;&#123;[[Template:unblock|unblock]]&#125;&#125; template.', explanation = 'If you cannot edit this user talk page and you need to' .. ' make a change or leave a message, you can' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for edits to a protected page' .. '|request an edit]],' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for reduction in protection level' .. '|request unprotection]],' .. ' [[Special:Userlogin|log in]],' .. ' or [[Special:UserLogin/signup|create an account]].', }, vandalism = { description = 'For pages protected against' .. ' [[Wikipedia:Vandalism|vandalism]]', text = '${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].', explanation = function (protectionObj, args) local ret = '' if protectionObj.level == 'sysop' then ret = ret .. "This protection is '''not''' an endorsement of the" .. ' ${CURRENTVERSION}. ' end return ret .. '${EXPLANATIONBLURB}' end, tooltip = '${TOOLTIPFRAGMENT} due to vandalism', } }, move = { dispute = { description = 'For pages protected against page moves due to' .. ' disputes over the page title', explanation = "This protection is '''not''' an endorsement of the" .. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}', image = 'Move-protection-shackle.svg' }, vandalism = { description = 'For pages protected against' .. ' [[Wikipedia:Vandalism#Page-move vandalism' .. ' |page-move vandalism]]' } }, autoreview = {}, upload = {} }, -------------------------------------------------------------------------------- -- -- GENERAL DATA TABLES -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Protection blurbs -------------------------------------------------------------------------------- -- This table produces the protection blurbs available with the -- ${PROTECTIONBLURB} parameter. It is sorted by protection action and -- protection level, and is checked by the module in the following order: -- 1. page's protection action, page's protection level -- 2. page's protection action, default protection level -- 3. "edit" protection action, default protection level -- -- It is possible to use banner parameters inside this table. -- *required* - this table needs edit, move, autoreview and upload subtables. protectionBlurbs = { edit = { default = 'This ${PAGETYPE} is currently [[Help:Protection|' .. 'protected]] from editing', autoconfirmed = 'Editing of this ${PAGETYPE} by [[Wikipedia:User access' .. ' levels#New users|new]] or [[Wikipedia:User access levels#Unregistered' .. ' users|unregistered]] users is currently [[Help:Protection|disabled]]', extendedconfirmed = 'This ${PAGETYPE} is currently under extended confirmed protection', }, move = { default = 'This ${PAGETYPE} is currently [[Help:Protection|protected]]' .. ' from [[Help:Moving a page|page moves]]' }, autoreview = { default = 'All edits made to this ${PAGETYPE} by' .. ' [[Wikipedia:User access levels#New users|new]] or' .. ' [[Wikipedia:User access levels#Unregistered users|unregistered]]' .. ' users are currently' .. ' [[Wikipedia:Pending changes|subject to review]]' }, upload = { default = 'Uploading new versions of this ${PAGETYPE} is currently disabled' } }, -------------------------------------------------------------------------------- -- Explanation blurbs -------------------------------------------------------------------------------- -- This table produces the explanation blurbs available with the -- ${EXPLANATIONBLURB} parameter. It is sorted by protection action, -- protection level, and whether the page is a talk page or not. If the page is -- a talk page it will have a talk key of "talk"; otherwise it will have a talk -- key of "subject". The table is checked in the following order: -- 1. page's protection action, page's protection level, page's talk key -- 2. page's protection action, page's protection level, default talk key -- 3. page's protection action, default protection level, page's talk key -- 4. page's protection action, default protection level, default talk key -- -- It is possible to use banner parameters inside this table. -- *required* - this table needs edit, move, autoreview and upload subtables. explanationBlurbs = { edit = { autoconfirmed = { subject = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details. If you' .. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can' .. ' ${EDITREQUEST}, discuss changes on the ${TALKPAGE},' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for reduction in protection level' .. '|request unprotection]], [[Special:Userlogin|log in]], or' .. ' [[Special:UserLogin/signup|create an account]].', default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details. If you' .. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for reduction in protection level' .. '|request unprotection]], [[Special:Userlogin|log in]], or' .. ' [[Special:UserLogin/signup|create an account]].', }, extendedconfirmed = { default = 'Extended confirmed protection prevents edits from all unregistered editors' .. ' and registered users with fewer than 30 days tenure and 500 edits.' .. ' The [[Wikipedia:Protection policy#extended|policy on community use]]' .. ' specifies that extended confirmed protection can be applied to combat' .. ' disruption, if semi-protection has proven to be ineffective.' .. ' Extended confirmed protection may also be applied to enforce' .. ' [[Wikipedia:Arbitration Committee|arbitration sanctions]].' .. ' Please discuss any changes on the ${TALKPAGE}; you may' .. ' ${EDITREQUEST} to ask for uncontroversial changes supported by' .. ' [[Wikipedia:Consensus|consensus]].' }, default = { subject = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' Please discuss any changes on the ${TALKPAGE}; you' .. ' may ${EDITREQUEST} to ask an' .. ' [[Wikipedia:Administrators|administrator]] to make an edit if it' .. ' is [[Help:Minor edit#When to mark an edit as a minor edit' .. '|uncontroversial]] or supported by [[Wikipedia:Consensus' .. '|consensus]]. You may also [[Wikipedia:Requests for' .. ' page protection#Current requests for reduction in protection level' .. '|request]] that this page be unprotected.', default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' You may [[Wikipedia:Requests for page' .. ' protection#Current requests for edits to a protected page|request an' .. ' edit]] to this page, or [[Wikipedia:Requests for' .. ' page protection#Current requests for reduction in protection level' .. '|ask]] for it to be unprotected.' } }, move = { default = { subject = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' The page may still be edited but cannot be moved' .. ' until unprotected. Please discuss any suggested moves on the' .. ' ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also' .. ' [[Wikipedia:Requests for page protection|request]] that the page be' .. ' unprotected.', default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' The page may still be edited but cannot be moved' .. ' until unprotected. Please discuss any suggested moves at' .. ' [[Wikipedia:Requested moves]]. You can also' .. ' [[Wikipedia:Requests for page protection|request]] that the page be' .. ' unprotected.' } }, autoreview = { default = { default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' Edits to this ${PAGETYPE} by new and unregistered users' .. ' will not be visible to readers until they are accepted by' .. ' a reviewer. To avoid the need for your edits to be' .. ' reviewed, you may' .. ' [[Wikipedia:Requests for page protection' .. '#Current requests for reduction in protection level' .. '|request unprotection]], [[Special:Userlogin|log in]], or' .. ' [[Special:UserLogin/signup|create an account]].' }, }, upload = { default = { default = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' The page may still be edited but new versions of the file' .. ' cannot be uploaded until it is unprotected. You can' .. ' request that a new version be uploaded by using a' .. ' [[Wikipedia:Edit requests|protected edit request]], or you' .. ' can [[Wikipedia:Requests for page protection|request]]' .. ' that the file be unprotected.' } } }, -------------------------------------------------------------------------------- -- Protection levels -------------------------------------------------------------------------------- -- This table provides the data for the ${PROTECTIONLEVEL} parameter, which -- produces a short label for different protection levels. It is sorted by -- protection action and protection level, and is checked in the following -- order: -- 1. page's protection action, page's protection level -- 2. page's protection action, default protection level -- 3. "edit" protection action, default protection level -- -- It is possible to use banner parameters inside this table. -- *required* - this table needs edit, move, autoreview and upload subtables. protectionLevels = { edit = { default = 'protected', templateeditor = 'template-protected', extendedconfirmed = 'extended-protected', autoconfirmed = 'semi-protected', }, move = { default = 'move-protected' }, autoreview = { }, upload = { default = 'upload-protected' } }, -------------------------------------------------------------------------------- -- Images -------------------------------------------------------------------------------- -- This table lists different padlock images for each protection action and -- protection level. It is used if an image is not specified in any of the -- banner data tables, and if the page does not satisfy the conditions for using -- the ['image-filename-indef'] image. It is checked in the following order: -- 1. page's protection action, page's protection level -- 2. page's protection action, default protection level images = { edit = { default = 'Full-protection-shackle.svg', templateeditor = 'Template-protection-shackle.svg', extendedconfirmed = 'Extended-protection-shackle.svg', autoconfirmed = 'Semi-protection-shackle.svg' }, move = { default = 'Move-protection-shackle.svg', }, autoreview = { default = 'Pending-protection-shackle.svg' }, upload = { default = 'Upload-protection-shackle.svg' } }, -- Pages with a reason specified in this table will show the special "indef" -- padlock, defined in the 'image-filename-indef' message, if no expiry is set. indefImageReasons = { template = true }, -------------------------------------------------------------------------------- -- Image links -------------------------------------------------------------------------------- -- This table provides the data for the ${IMAGELINK} parameter, which gets -- the image link for small padlock icons based on the page's protection action -- and protection level. It is checked in the following order: -- 1. page's protection action, page's protection level -- 2. page's protection action, default protection level -- 3. "edit" protection action, default protection level -- -- It is possible to use banner parameters inside this table. -- *required* - this table needs edit, move, autoreview and upload subtables. imageLinks = { edit = { default = 'Wikipedia:Protection policy#full', templateeditor = 'Wikipedia:Protection policy#template', extendedconfirmed = 'Wikipedia:Protection policy#extended', autoconfirmed = 'Wikipedia:Protection policy#semi' }, move = { default = 'Wikipedia:Protection policy#move' }, autoreview = { default = 'Wikipedia:Protection policy#pending' }, upload = { default = 'Wikipedia:Protection policy#upload' } }, -------------------------------------------------------------------------------- -- Padlock indicator names -------------------------------------------------------------------------------- -- This table provides the "name" attribute for the <indicator> extension tag -- with which small padlock icons are generated. All indicator tags on a page -- are displayed in alphabetical order based on this attribute, and with -- indicator tags with duplicate names, the last tag on the page wins. -- The attribute is chosen based on the protection action; table keys must be a -- protection action name or the string "default". padlockIndicatorNames = { autoreview = 'pp-autoreview', default = 'pp-default' }, -------------------------------------------------------------------------------- -- Protection categories -------------------------------------------------------------------------------- --[[ -- The protection categories are stored in the protectionCategories table. -- Keys to this table are made up of the following strings: -- -- 1. the expiry date -- 2. the namespace -- 3. the protection reason (e.g. "dispute" or "vandalism") -- 4. the protection level (e.g. "sysop" or "autoconfirmed") -- 5. the action (e.g. "edit" or "move") -- -- When the module looks up a category in the table, first it will will check to -- see a key exists that corresponds to all five parameters. For example, a -- user page semi-protected from vandalism for two weeks would have the key -- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module -- changes the first part of the key to "all" and checks the table again. It -- keeps checking increasingly generic key combinations until it finds the -- field, or until it reaches the key "all-all-all-all-all". -- -- The module uses a binary matrix to determine the order in which to search. -- This is best demonstrated by a table. In this table, the "0" values -- represent "all", and the "1" values represent the original data (e.g. -- "indef" or "file" or "vandalism"). -- -- expiry namespace reason level action -- order -- 1 1 1 1 1 1 -- 2 0 1 1 1 1 -- 3 1 0 1 1 1 -- 4 0 0 1 1 1 -- 5 1 1 0 1 1 -- 6 0 1 0 1 1 -- 7 1 0 0 1 1 -- 8 0 0 0 1 1 -- 9 1 1 1 0 1 -- 10 0 1 1 0 1 -- 11 1 0 1 0 1 -- 12 0 0 1 0 1 -- 13 1 1 0 0 1 -- 14 0 1 0 0 1 -- 15 1 0 0 0 1 -- 16 0 0 0 0 1 -- 17 1 1 1 1 0 -- 18 0 1 1 1 0 -- 19 1 0 1 1 0 -- 20 0 0 1 1 0 -- 21 1 1 0 1 0 -- 22 0 1 0 1 0 -- 23 1 0 0 1 0 -- 24 0 0 0 1 0 -- 25 1 1 1 0 0 -- 26 0 1 1 0 0 -- 27 1 0 1 0 0 -- 28 0 0 1 0 0 -- 29 1 1 0 0 0 -- 30 0 1 0 0 0 -- 31 1 0 0 0 0 -- 32 0 0 0 0 0 -- -- In this scheme the action has the highest priority, as it is the last -- to change, and the expiry has the least priority, as it changes the most. -- The priorities of the expiry, the protection level and the action are -- fixed, but the priorities of the reason and the namespace can be swapped -- through the use of the cfg.bannerDataNamespaceHasPriority table. --]] -- If the reason specified to the template is listed in this table, -- namespace data will take priority over reason data in the protectionCategories -- table. reasonsWithNamespacePriority = { vandalism = true, }, -- The string to use as a namespace key for the protectionCategories table for each -- namespace number. categoryNamespaceKeys = { [ 2] = 'user', [ 3] = 'user', [ 4] = 'project', [ 6] = 'file', [ 8] = 'mediawiki', [ 10] = 'template', [ 12] = 'project', [ 14] = 'category', [100] = 'portal', [828] = 'module', }, protectionCategories = { ['all|all|all|all|all'] = 'Wikipedia fully protected pages', ['all|all|office|all|all'] = 'Wikipedia Office-protected pages', ['all|all|reset|all|all'] = 'Wikipedia Office-protected pages', ['all|all|dmca|all|all'] = 'Wikipedia Office-protected pages', ['all|all|mainpage|all|all'] = 'Wikipedia fully protected main page files', ['all|all|all|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages', ['all|all|ecp|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages', ['all|template|all|all|edit'] = 'Wikipedia fully protected templates', ['all|all|all|autoconfirmed|edit'] = 'Wikipedia semi-protected pages', ['indef|all|all|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected pages', ['all|all|blp|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected biographies of living people', ['temp|all|blp|autoconfirmed|edit'] = 'Wikipedia temporarily semi-protected biographies of living people', ['all|all|dispute|autoconfirmed|edit'] = 'Wikipedia pages semi-protected due to dispute', ['all|all|sock|autoconfirmed|edit'] = 'Wikipedia pages semi-protected from banned users', ['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism', ['all|category|all|autoconfirmed|edit'] = 'Wikipedia semi-protected categories', ['all|file|all|autoconfirmed|edit'] = 'Wikipedia semi-protected files', ['all|portal|all|autoconfirmed|edit'] = 'Wikipedia semi-protected portals', ['all|project|all|autoconfirmed|edit'] = 'Wikipedia semi-protected project pages', ['all|talk|all|autoconfirmed|edit'] = 'Wikipedia semi-protected talk pages', ['all|template|all|autoconfirmed|edit'] = 'Wikipedia semi-protected templates', ['all|user|all|autoconfirmed|edit'] = 'Wikipedia semi-protected user and user talk pages', ['all|all|all|templateeditor|move'] = 'Wikipedia template-protected pages other than templates and modules', ['all|all|all|templateeditor|edit'] = 'Wikipedia template-protected pages other than templates and modules', ['all|template|all|templateeditor|edit'] = 'Wikipedia template-protected templates', ['all|template|all|templateeditor|move'] = 'Wikipedia template-protected templates', -- move-protected templates ['all|all|blp|sysop|edit'] = 'Wikipedia indefinitely protected biographies of living people', ['temp|all|blp|sysop|edit'] = 'Wikipedia temporarily protected biographies of living people', ['all|all|dispute|sysop|edit'] = 'Wikipedia pages protected due to dispute', ['all|all|sock|sysop|edit'] = 'Wikipedia pages protected from banned users', ['all|all|vandalism|sysop|edit'] = 'Wikipedia pages protected against vandalism', ['all|category|all|sysop|edit'] = 'Wikipedia fully protected categories', ['all|file|all|sysop|edit'] = 'Wikipedia fully protected files', ['all|project|all|sysop|edit'] = 'Wikipedia fully protected project pages', ['all|talk|all|sysop|edit'] = 'Wikipedia fully protected talk pages', ['all|template|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected templates', ['all|template|all|sysop|edit'] = 'Wikipedia fully protected templates', ['all|user|all|sysop|edit'] = 'Wikipedia fully protected user and user talk pages', ['all|module|all|all|edit'] = 'Wikipedia fully protected modules', ['all|module|all|templateeditor|edit'] = 'Wikipedia template-protected modules', ['all|module|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected modules', ['all|module|all|autoconfirmed|edit'] = 'Wikipedia semi-protected modules', ['all|all|all|sysop|move'] = 'Wikipedia move-protected pages', ['indef|all|all|sysop|move'] = 'Wikipedia indefinitely move-protected pages', ['all|all|dispute|sysop|move'] = 'Wikipedia pages move-protected due to dispute', ['all|all|vandalism|sysop|move'] = 'Wikipedia pages move-protected due to vandalism', ['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals', ['all|project|all|sysop|move'] = 'Wikipedia move-protected project pages', ['all|talk|all|sysop|move'] = 'Wikipedia move-protected talk pages', ['all|template|all|sysop|move'] = 'Wikipedia move-protected templates', ['all|user|all|sysop|move'] = 'Wikipedia move-protected user and user talk pages', ['all|all|all|autoconfirmed|autoreview'] = 'Wikipedia pending changes protected pages', ['all|file|all|all|upload'] = 'Wikipedia upload-protected files', }, -------------------------------------------------------------------------------- -- Expiry category config -------------------------------------------------------------------------------- -- This table configures the expiry category behaviour for each protection -- action. -- * If set to true, setting that action will always categorise the page if -- an expiry parameter is not set. -- * If set to false, setting that action will never categorise the page. -- * If set to nil, the module will categorise the page if: -- 1) an expiry parameter is not set, and -- 2) a reason is provided, and -- 3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck -- table. expiryCheckActions = { edit = nil, move = false, autoreview = true, upload = false }, reasonsWithoutExpiryCheck = { blp = true, template = true, }, -------------------------------------------------------------------------------- -- Pagetypes -------------------------------------------------------------------------------- -- This table produces the page types available with the ${PAGETYPE} parameter. -- Keys are namespace numbers, or the string "default" for the default value. pagetypes = { [0] = 'article', [6] = 'file', [10] = 'template', [14] = 'category', [828] = 'module', default = 'page' }, -------------------------------------------------------------------------------- -- Strings marking indefinite protection -------------------------------------------------------------------------------- -- This table contains values passed to the expiry parameter that mean the page -- is protected indefinitely. indefStrings = { ['indef'] = true, ['indefinite'] = true, ['indefinitely'] = true, ['infinite'] = true, }, -------------------------------------------------------------------------------- -- Group hierarchy -------------------------------------------------------------------------------- -- This table maps each group to all groups that have a superset of the original -- group's page editing permissions. hierarchy = { sysop = {}, reviewer = {'sysop'}, filemover = {'sysop'}, templateeditor = {'sysop'}, extendedconfirmed = {'sysop'}, autoconfirmed = {'reviewer', 'filemover', 'templateeditor', 'extendedconfirmed'}, user = {'autoconfirmed'}, ['*'] = {'user'} }, -------------------------------------------------------------------------------- -- Wrapper templates and their default arguments -------------------------------------------------------------------------------- -- This table contains wrapper templates used with the module, and their -- default arguments. Templates specified in this table should contain the -- following invocation, and no other template content: -- -- {{#invoke:Protection banner|main}} -- -- If other content is desired, it can be added between -- <noinclude>...</noinclude> tags. -- -- When a user calls one of these wrapper templates, they will use the -- default arguments automatically. However, users can override any of the -- arguments. wrappers = { ['Template:Pp'] = {}, ['Template:Pp-extended'] = {'ecp'}, ['Template:Pp-blp'] = {'blp'}, -- we don't need Template:Pp-create ['Template:Pp-dispute'] = {'dispute'}, ['Template:Pp-main-page'] = {'mainpage'}, ['Template:Pp-move'] = {action = 'move', catonly = 'yes'}, ['Template:Pp-move-dispute'] = {'dispute', action = 'move', catonly = 'yes'}, -- we don't need Template:Pp-move-indef ['Template:Pp-move-vandalism'] = {'vandalism', action = 'move', catonly = 'yes'}, ['Template:Pp-office'] = {'office'}, ['Template:Pp-office-dmca'] = {'dmca'}, ['Template:Pp-pc'] = {action = 'autoreview', small = true}, ['Template:Pp-pc1'] = {action = 'autoreview', small = true}, ['Template:Pp-reset'] = {'reset'}, ['Template:Pp-semi-indef'] = {small = true}, ['Template:Pp-sock'] = {'sock'}, ['Template:Pp-template'] = {'template', small = true}, ['Template:Pp-upload'] = {action = 'upload'}, ['Template:Pp-usertalk'] = {'usertalk'}, ['Template:Pp-vandalism'] = {'vandalism'}, }, -------------------------------------------------------------------------------- -- -- MESSAGES -- -------------------------------------------------------------------------------- msg = { -------------------------------------------------------------------------------- -- Intro blurb and intro fragment -------------------------------------------------------------------------------- -- These messages specify what is produced by the ${INTROBLURB} and -- ${INTROFRAGMENT} parameters. If the protection is temporary they use the -- intro-blurb-expiry or intro-fragment-expiry, and if not they use -- intro-blurb-noexpiry or intro-fragment-noexpiry. -- It is possible to use banner parameters in these messages. ['intro-blurb-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY}.', ['intro-blurb-noexpiry'] = '${PROTECTIONBLURB}.', ['intro-fragment-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY},', ['intro-fragment-noexpiry'] = '${PROTECTIONBLURB}', -------------------------------------------------------------------------------- -- Tooltip blurb -------------------------------------------------------------------------------- -- These messages specify what is produced by the ${TOOLTIPBLURB} parameter. -- If the protection is temporary the tooltip-blurb-expiry message is used, and -- if not the tooltip-blurb-noexpiry message is used. -- It is possible to use banner parameters in these messages. ['tooltip-blurb-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.', ['tooltip-blurb-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}.', ['tooltip-fragment-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},', ['tooltip-fragment-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}', -------------------------------------------------------------------------------- -- Special explanation blurb -------------------------------------------------------------------------------- -- An explanation blurb for pages that cannot be unprotected, e.g. for pages -- in the MediaWiki namespace. -- It is possible to use banner parameters in this message. ['explanation-blurb-nounprotect'] = 'See the [[Wikipedia:Protection policy|' .. 'protection policy]] and ${PROTECTIONLOG} for more details.' .. ' Please discuss any changes on the ${TALKPAGE}; you' .. ' may ${EDITREQUEST} to ask an' .. ' [[Wikipedia:Administrators|administrator]] to make an edit if it' .. ' is [[Help:Minor edit#When to mark an edit as a minor edit' .. '|uncontroversial]] or supported by [[Wikipedia:Consensus' .. '|consensus]].', -------------------------------------------------------------------------------- -- Protection log display values -------------------------------------------------------------------------------- -- These messages determine the display values for the protection log link -- or the pending changes log link produced by the ${PROTECTIONLOG} parameter. -- It is possible to use banner parameters in these messages. ['protection-log-display'] = 'protection log', ['pc-log-display'] = 'pending changes log', -------------------------------------------------------------------------------- -- Current version display values -------------------------------------------------------------------------------- -- These messages determine the display values for the page history link -- or the move log link produced by the ${CURRENTVERSION} parameter. -- It is possible to use banner parameters in these messages. ['current-version-move-display'] = 'current title', ['current-version-edit-display'] = 'current version', -------------------------------------------------------------------------------- -- Talk page -------------------------------------------------------------------------------- -- This message determines the display value of the talk page link produced -- with the ${TALKPAGE} parameter. -- It is possible to use banner parameters in this message. ['talk-page-link-display'] = 'talk page', -------------------------------------------------------------------------------- -- Edit requests -------------------------------------------------------------------------------- -- This message determines the display value of the edit request link produced -- with the ${EDITREQUEST} parameter. -- It is possible to use banner parameters in this message. ['edit-request-display'] = 'submit an edit request', -------------------------------------------------------------------------------- -- Expiry date format -------------------------------------------------------------------------------- -- This is the format for the blurb expiry date. It should be valid input for -- the first parameter of the #time parser function. ['expiry-date-format'] = 'F j, Y "at" H:i e', -------------------------------------------------------------------------------- -- Tracking categories -------------------------------------------------------------------------------- -- These messages determine which tracking categories the module outputs. ['tracking-category-incorrect'] = 'Wikipedia pages with incorrect protection templates', ['tracking-category-template'] = 'Wikipedia template-protected pages other than templates and modules', -------------------------------------------------------------------------------- -- Images -------------------------------------------------------------------------------- -- These are images that are not defined by their protection action and protection level. ['image-filename-indef'] = 'Full-protection-shackle.svg', ['image-filename-default'] = 'Transparent.gif', -------------------------------------------------------------------------------- -- End messages -------------------------------------------------------------------------------- } -------------------------------------------------------------------------------- -- End configuration -------------------------------------------------------------------------------- } 65de905227752d0a0dae145e9ad8dbe1d0087016 Template:Yesno-no 10 42 83 82 2024-04-03T17:30:59Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Yesno-no]] wikitext text/x-wiki {{safesubst:<noinclude />yesno|{{{1}}}|yes={{{yes|yes}}}|no={{{no|no}}}|blank={{{blank|no}}}|¬={{{¬|no}}}|def={{{def|no}}}}}<noinclude> {{Documentation|Template:Yesno/doc}} <!--Categories go in the doc page referenced above; interwikis go in Wikidata.--> </noinclude> 1ad7b7800da1b867ead8f6ff8cef76e6201b3b56 Template:Asbox 10 26 85 48 2024-04-03T17:30:59Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Asbox]] wikitext text/x-wiki <includeonly>{{#invoke:Asbox|main}}</includeonly><noinclude> {{documentation}} <!-- Add categories to the /doc subpage and interwikis to Wikidata. --> </noinclude> b20553d60f223a0f36a3089524989e235d379b74 Template:Asbox/styles.css 10 28 87 50 2024-04-03T17:31:00Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Asbox/styles.css]] sanitized-css text/css /* {{pp-template}} */ /* Article stub message box styles */ .asbox { position: relative; overflow:hidden; } .asbox table { background: transparent; } .asbox p { margin: 0; } .asbox p + p { margin-top: 0.25em; } .asbox-body { font-style: italic; } .asbox-note { font-size: smaller; } .asbox .navbar { position: absolute; top: -0.75em; right: 1em; display: none; } 9f0904fdac11fd6eebd84c73d5680f09d19c9b5a Module:Asbox 828 27 89 49 2024-04-03T17:31:00Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Asbox]] Scribunto text/plain --[[ This module was created by User:CodeHydro (Alexander Zhikun He). User:Jackmcbarn and User:Mr._Stradivarius provided a great deal of assistance in writting p.main() p.main() draw heavily from the following version of Template:Asbox of the English Wikipedia, authored primarily by User:Rich_Farmbrough https://en.wikipedia.org/w/index.php?title=Template:Asbox&oldid=619510287 p.templatepage() is derived from the following revision of Template:Asbox/templatepage, authored primarily by User:MSGJ https://en.wikipedia.org/w/index.php?title=Template:Asbox/templatepage&oldid=632914791 Both templates had significant contributions from numerous others listed in the revision history tab of their respective pages. --]] local WRAPPER_TEMPLATE, args = 'Template:Asbox' local templatestyles = 'Asbox/styles.css' local p, Buffer, stubCats = { --Prevents dupli-cats... get it? Maybe not? cats = setmetatable({}, {__newindex = function(t, i, v) if not rawget(t, i) then rawset(t, i, v) table.insert(t, i) end end}), --initializes variables required by both p.main and p.templatepage init = function(self, frame, page) args, page = args or require('Module:Arguments').getArgs(frame, { wrappers = WRAPPER_TEMPLATE }), page or mw.title.getCurrentTitle() --Ensures demo parameter will never affect category() output for articles self.demo = self.demo or page.namespace ~= 0 and args.demo return args, page end }, require('Module:Buffer') --[[ Formats category links. Stores them until called with cat.done=true Takes multiple or single categories in the form of 'cat' or a table of strings and/or tables containing parts. (See below) ]] local attention, catTag, catKey = Buffer'Stub message templates needing attention', '[[Category:%s]]', '%s|%s%s' local function category(cat) for _, v in ipairs((tostring(cat) == cat or cat.t) and {cat} or cat) do --[[ If v is a table: [1] = full category name; defaults to local attention if blank k = Category sort key. Prefix before v.t t = page.text or args.tempsort#; appended after k (or in its place if omitted). Required if v is not a string Basically the same as v = (v[1] or attention) .. ' | ' .. (v.k or '') .. v.t ]] if v and v ~= true then--reject v = nil, false, or true p.cats[catTag:format(tostring(v) == v and v or (v[1] and Buffer(v[1]) or attention):_in(v.k):_(v.t):_str(2, nil, nil, '|') )] = true end end return cat.done and table.concat(p.cats, p.demo and ' | ' or nil) or '' end --[[ Makes an ombox warning; Takes table {ifNot = Boolean, text, {cat. sort key, cat. sort name}} Will return an empty string instead when ifNot evaluates to true ]] local function ombox(v) if v.ifNot then return end p.ombox = p.ombox or require('Module:Message box').ombox category{v[2]} return p.ombox{ type = 'content', text = v[1] } end --[[ Unlike original template, module now takes unlimited cats! This function also performs most stub category error checks except for the ombox for when main |category= is omitted (See p.template()) ]] local function catStub(page, pageDoc) stubCats = {missing = {}, v = {}} -- zwj and zwnj have semantical use in other other wikis, don't remove them local zwj = '\226\128\141' -- U+200D, E2 80 8D local zwnj = '\226\128\140' -- U+200C, E2 80 8C local disallowedUnicodeChars = '[^%w%p%s' .. zwj .. zwnj .. ']' -- for i18n we make this a separate string local code for k, _ in pairs(args) do --Find category parameters and store the number (main cat = '') table.insert(stubCats, string.match(k, '^category(%d*)$')) end table.sort(stubCats) for k, v in ipairs(stubCats) do --Get category names and, if called by p.templatepage, the optional sort key local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], disallowedUnicodeChars, '')--remove all hidden unicode chars --Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category. table.insert(stubCats.v, page and (--p.templatepage passes page; p.main does not, i.e. articles are categorized without sort keys. v=='' and tsort == 'no'--if true, inserts 'true' in table, which category() will reject or tsort and {cat, k = ' ', t = tsort} or {cat, k = ' *', t = page.text}--note space in front of sort key ) or cat ) --Check category existance only if on the template page (i.e. stub documentation) if page then if not mw.title.new('Category:' .. cat).exists then code = code or mw.html.create'code':wikitext'|category' table.insert(stubCats.missing, tostring(mw.clone(code):wikitext(v))) end --[[ Checks non-demo stub template for documentation and flags if doc is present. All stub cats names are checked and flagged if it does not match 'Category: [] stub'. The main stub cat is exempt from the name check if the stub template has its own doc (presumably, this doc would have an explanation as to why the main stub cat is non-conforming). ]] table.insert(stubCats.v, v == '' and not p.demo and pageDoc.exists and 'Stub message templates with documentation subpages' or not cat:match' stubs$' and {k = 'S', t = page.text} ) end end --Add category names after loop is completed category(stubCats.v) return #stubCats.missing > 0 and ombox{ --Changed, original msg: --One or more of the stub categories defined in this template do not seem to exist! --Please double-check the parameters {{para|category}}, {{para|category1}} and {{para|category2}}. 'The following parameter' .. (#stubCats.missing == 1 and ' defines a stub category that does' or 's define stub categories that do') .. ' not exist: ' .. mw.text.listToText(stubCats.missing), {k = 'N', t = page.text} } end --Shows population of categories found by catStub(). Outputs demo values if none local function population() local wikitext, base = {}, '* [[:Category:%s]] (population: %s)\n' if not args.category and stubCats[1] ~= false then table.insert(stubCats, 1, false) end for _, v in ipairs(stubCats) do table.insert(wikitext, base:format( v and args['category' .. v] or '{{{category}}}', v and mw.site.stats.pagesInCategory(args['category' .. v], 'all') or 0 )) end return table.concat(wikitext) end --Includes standard stub documention and flags stub templates with bad parameter values. function p.templatepage(frame, page) args, page = p:init(frame, page) local tStubDoc = mw.title.new'Template:Stub documentation' local pageDoc = page:subPageTitle('doc') --Reorganization note: Original Asbox alternates between outputting categories and checking on params |category#=. --Rather than checking multiple times and switching tasks, all stub category param operations have been rolled into catStub() return Buffer( ombox{--Show ombox warnings for missing args. ifNot = args.category, 'The <code>|category</code> parameter is not set. Please add an appropriate stub category.', {k = 'C', t = page.text} }) :_(ombox{ ifNot = args.subject or args.article or args.qualifier, 'This stub template contains no description! At least one of the parameters <code>|subject</code>, <code>|article</code> or <code>|qualifier</code> must be defined.', {k = 'D', t = page.text} }) :_(catStub(page, pageDoc))--catStub() may also return an ombox if there are non-existing categories :_(category{ done = p.demo ~= 'doc',--Outputs categories if not doc demo 'Stub message templates', args.icon and 'Stub message templates using icon parameter' or args.image and ( mw.title.new('Media:' .. mw.text.split(args.image, '|')[1]).exists--do nothing if exists. category() will reject true or {k = 'B', t = page.text} ) or 'Stub message templates without images', args.imagealt and {k = 'I', t = page.text}, }) :_((not p.demo or p.demo == 'doc') and--Add standard stub template documentation require('Module:Documentation').main{ content = Buffer(page.text ~= 'Stub' and--This comparison performed in {{Asbox/stubtree}} before it invokes Module:Asbox stubtree require('Module:Asbox stubtree').subtree{args = {pagename = page.text}} ) :_in'\n== About this template ==\nThis template is used to identify a':_(args.subject):_'stub':_(args.qualifier):_out' '--space :_'. It uses {{[[Template:Asbox|asbox]]}}, which is a meta-template designed to ease the process of creating and maintaining stub templates.\n=== Usage ===\nTyping ' :_(mw.html.create'code' :wikitext('{{', page.text == 'Stub' and 'stub' or page.text, '}}') ) :_' produces the message shown at the beginning, and adds the article to the following categor' :_(#stubCats > 1 and 'ies' or 'y') :_':\n' :_(population()) :_(pageDoc.exists and--transclusion of /doc if it exists frame:expandTemplate{title = pageDoc.text} ) :_'\n== General information ==\n' :_(frame:expandTemplate{title = tStubDoc.text}) :_'\n\n'(), ['link box'] = Buffer'This documentation is automatically generated by [[Module:Asbox]].' :_in'The general information is transcluded from [[Template:Stub documentation]]. ' :_(mw.html.create'span' :cssText'font-size:smaller;font-style:normal;line-height:130%' :node(('([%s edit] | [%s history])'):format( tStubDoc:fullUrl('action=edit', 'relative'), tStubDoc:fullUrl('action=history', 'relative') )) ) :_out() :_(page.protectionLevels.edit and page.protectionLevels.edit[1] == 'sysop' and "This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template's [" .. pageDoc:fullUrl('action=edit&preload=Template:Category_interwiki/preload', 'relative') .. '| /doc] subpage, which is not protected.' )' <br/>' } )() end function p.main(frame, page) args, page = p:init(frame, page) local output = mw.html.create'div' :attr{role = 'note'} :addClass'metadata plainlinks asbox stub' :tag'table' :attr{role = 'presentation'} :tag'tr' :addClass'noresize' :node((args.icon or args.image) and mw.html.create'td' :wikitext(args.icon or ('[[File:%s|%spx|alt=%s]]'):format( args.image or '', args.pix or '40x30', args.imagealt or 'Stub icon' )) ) :tag'td' :tag'p' :addClass'asbox-body' :wikitext( Buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space ' is a [[Wikipedia:stub|stub]]. You can help Wikipedia by [', page:fullUrl('action=edit', 'relative'), ' expanding it].' ) :done() :node(args.note and mw.html.create() :tag'p' :addClass'asbox-note' :wikitext(args.note) :done() ) :allDone() :node(args.name and require'Module:Navbar'._navbar{ args.name, mini = 'yes', } ) --[[ Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories. Articles using the template do not need a sort key since they have unique names. When p.demo equals 'doc', the demo stub categories will appear as those for a stub template. Otherwise, any non-nil p.demo will emulate article space categories (plus any error cats unless set to 'art') ]] if page.namespace == 0 then -- Main namespace category'All stub articles' catStub() elseif p.demo then if p.demo ~= 'doc' then catStub() end --Unless p.demo is set to 'art', it will also include error categories normally only shown on --the template but not in the article. The elseif after namespace == 0 means demo cats will never show in article space. p.demodoc = p.demo ~= 'art' and p.templatepage(frame, page) output = mw.html.create() :node(output) :tag'small':wikitext( 'Demo categories: ', (category{done = true}:gsub('(%[%[)(Category:)([^|%]]-)(%|)', '%1%2%3|%2%3%4'):gsub('(%[%[)(Category:)', '%1:%2')) ):done() :wikitext(p.demo == 'doc' and p.demodoc or nil) else --Checks for valid name; emulates original template's check using {{FULLPAGENAME:{{{name|}}}}} local normalizedName = mw.title.new(args.name or '') if normalizedName and normalizedName.fullText == page.fullText then output = mw.html.create():node(output):wikitext(p.templatepage(frame, page)) elseif not page.isSubpage and page.namespace == 10 then-- Template namespace and not a subpage category{{k = args.name and 'E' or 'W', t = page.text}} end end return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(output:wikitext(not p.demo and category{done = true} or nil)) end return p 0a9850f35fe9b15eaadd5d693d751ca62ddb60cf 137 89 2024-04-03T17:36:09Z Nulcow 2 Scribunto text/plain --[[ This module was created by User:CodeHydro (Alexander Zhikun He). User:Jackmcbarn and User:Mr._Stradivarius provided a great deal of assistance in writting p.main() p.main() draw heavily from the following version of Template:Asbox of the English Wikipedia, authored primarily by User:Rich_Farmbrough https://en.wikipedia.org/w/index.php?title=Template:Asbox&oldid=619510287 p.templatepage() is derived from the following revision of Template:Asbox/templatepage, authored primarily by User:MSGJ https://en.wikipedia.org/w/index.php?title=Template:Asbox/templatepage&oldid=632914791 Both templates had significant contributions from numerous others listed in the revision history tab of their respective pages. --]] local WRAPPER_TEMPLATE, args = 'Template:Asbox' local templatestyles = 'Asbox/styles.css' local p, Buffer, stubCats = { --Prevents dupli-cats... get it? Maybe not? cats = setmetatable({}, {__newindex = function(t, i, v) if not rawget(t, i) then rawset(t, i, v) table.insert(t, i) end end}), --initializes variables required by both p.main and p.templatepage init = function(self, frame, page) args, page = args or require('Module:Arguments').getArgs(frame, { wrappers = WRAPPER_TEMPLATE }), page or mw.title.getCurrentTitle() --Ensures demo parameter will never affect category() output for articles self.demo = self.demo or page.namespace ~= 0 and args.demo return args, page end }, require('Module:Buffer') --[[ Formats category links. Stores them until called with cat.done=true Takes multiple or single categories in the form of 'cat' or a table of strings and/or tables containing parts. (See below) ]] local attention, catTag, catKey = Buffer'Stub message templates needing attention', '[[Category:%s]]', '%s|%s%s' local function category(cat) for _, v in ipairs((tostring(cat) == cat or cat.t) and {cat} or cat) do --[[ If v is a table: [1] = full category name; defaults to local attention if blank k = Category sort key. Prefix before v.t t = page.text or args.tempsort#; appended after k (or in its place if omitted). Required if v is not a string Basically the same as v = (v[1] or attention) .. ' | ' .. (v.k or '') .. v.t ]] if v and v ~= true then--reject v = nil, false, or true p.cats[catTag:format(tostring(v) == v and v or (v[1] and Buffer(v[1]) or attention):_in(v.k):_(v.t):_str(2, nil, nil, '|') )] = true end end return cat.done and table.concat(p.cats, p.demo and ' | ' or nil) or '' end --[[ Makes an ombox warning; Takes table {ifNot = Boolean, text, {cat. sort key, cat. sort name}} Will return an empty string instead when ifNot evaluates to true ]] local function ombox(v) if v.ifNot then return end p.ombox = p.ombox or require('Module:Message box').ombox category{v[2]} return p.ombox{ type = 'content', text = v[1] } end --[[ Unlike original template, module now takes unlimited cats! This function also performs most stub category error checks except for the ombox for when main |category= is omitted (See p.template()) ]] local function catStub(page, pageDoc) stubCats = {missing = {}, v = {}} -- zwj and zwnj have semantical use in other other wikis, don't remove them local zwj = '\226\128\141' -- U+200D, E2 80 8D local zwnj = '\226\128\140' -- U+200C, E2 80 8C local disallowedUnicodeChars = '[^%w%p%s' .. zwj .. zwnj .. ']' -- for i18n we make this a separate string local code for k, _ in pairs(args) do --Find category parameters and store the number (main cat = '') table.insert(stubCats, string.match(k, '^category(%d*)$')) end table.sort(stubCats) for k, v in ipairs(stubCats) do --Get category names and, if called by p.templatepage, the optional sort key local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], disallowedUnicodeChars, '')--remove all hidden unicode chars --Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category. table.insert(stubCats.v, page and (--p.templatepage passes page; p.main does not, i.e. articles are categorized without sort keys. v=='' and tsort == 'no'--if true, inserts 'true' in table, which category() will reject or tsort and {cat, k = ' ', t = tsort} or {cat, k = ' *', t = page.text}--note space in front of sort key ) or cat ) --Check category existance only if on the template page (i.e. stub documentation) if page then if not mw.title.new('Category:' .. cat).exists then code = code or mw.html.create'code':wikitext'|category' table.insert(stubCats.missing, tostring(mw.clone(code):wikitext(v))) end --[[ Checks non-demo stub template for documentation and flags if doc is present. All stub cats names are checked and flagged if it does not match 'Category: [] stub'. The main stub cat is exempt from the name check if the stub template has its own doc (presumably, this doc would have an explanation as to why the main stub cat is non-conforming). ]] table.insert(stubCats.v, v == '' and not p.demo and pageDoc.exists and 'Stub message templates with documentation subpages' or not cat:match' stubs$' and {k = 'S', t = page.text} ) end end --Add category names after loop is completed category(stubCats.v) return #stubCats.missing > 0 and ombox{ --Changed, original msg: --One or more of the stub categories defined in this template do not seem to exist! --Please double-check the parameters {{para|category}}, {{para|category1}} and {{para|category2}}. 'The following parameter' .. (#stubCats.missing == 1 and ' defines a stub category that does' or 's define stub categories that do') .. ' not exist: ' .. mw.text.listToText(stubCats.missing), {k = 'N', t = page.text} } end --Shows population of categories found by catStub(). Outputs demo values if none local function population() local wikitext, base = {}, '* [[:Category:%s]] (population: %s)\n' if not args.category and stubCats[1] ~= false then table.insert(stubCats, 1, false) end for _, v in ipairs(stubCats) do table.insert(wikitext, base:format( v and args['category' .. v] or '{{{category}}}', v and mw.site.stats.pagesInCategory(args['category' .. v], 'all') or 0 )) end return table.concat(wikitext) end --Includes standard stub documention and flags stub templates with bad parameter values. function p.templatepage(frame, page) args, page = p:init(frame, page) local tStubDoc = mw.title.new'Template:Stub documentation' local pageDoc = page:subPageTitle('doc') --Reorganization note: Original Asbox alternates between outputting categories and checking on params |category#=. --Rather than checking multiple times and switching tasks, all stub category param operations have been rolled into catStub() return Buffer( ombox{--Show ombox warnings for missing args. ifNot = args.category, 'The <code>|category</code> parameter is not set. Please add an appropriate stub category.', {k = 'C', t = page.text} }) :_(ombox{ ifNot = args.subject or args.article or args.qualifier, 'This stub template contains no description! At least one of the parameters <code>|subject</code>, <code>|article</code> or <code>|qualifier</code> must be defined.', {k = 'D', t = page.text} }) :_(catStub(page, pageDoc))--catStub() may also return an ombox if there are non-existing categories :_(category{ done = p.demo ~= 'doc',--Outputs categories if not doc demo 'Stub message templates', args.icon and 'Stub message templates using icon parameter' or args.image and ( mw.title.new('Media:' .. mw.text.split(args.image, '|')[1]).exists--do nothing if exists. category() will reject true or {k = 'B', t = page.text} ) or 'Stub message templates without images', args.imagealt and {k = 'I', t = page.text}, }) :_((not p.demo or p.demo == 'doc') and--Add standard stub template documentation require('Module:Documentation').main{ content = Buffer(page.text ~= 'Stub' and--This comparison performed in {{Asbox/stubtree}} before it invokes Module:Asbox stubtree require('Module:Asbox stubtree').subtree{args = {pagename = page.text}} ) :_in'\n== About this template ==\nThis template is used to identify a':_(args.subject):_'stub':_(args.qualifier):_out' '--space :_'. It uses {{[[Template:Asbox|asbox]]}}, which is a meta-template designed to ease the process of creating and maintaining stub templates.\n=== Usage ===\nTyping ' :_(mw.html.create'code' :wikitext('{{', page.text == 'Stub' and 'stub' or page.text, '}}') ) :_' produces the message shown at the beginning, and adds the article to the following categor' :_(#stubCats > 1 and 'ies' or 'y') :_':\n' :_(population()) :_(pageDoc.exists and--transclusion of /doc if it exists frame:expandTemplate{title = pageDoc.text} ) :_'\n== General information ==\n' :_(frame:expandTemplate{title = tStubDoc.text}) :_'\n\n'(), ['link box'] = Buffer'This documentation is automatically generated by [[Module:Asbox]].' :_in'The general information is transcluded from [[Template:Stub documentation]]. ' :_(mw.html.create'span' :cssText'font-size:smaller;font-style:normal;line-height:130%' :node(('([%s edit] | [%s history])'):format( tStubDoc:fullUrl('action=edit', 'relative'), tStubDoc:fullUrl('action=history', 'relative') )) ) :_out() :_(page.protectionLevels.edit and page.protectionLevels.edit[1] == 'sysop' and "This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template's [" .. pageDoc:fullUrl('action=edit&preload=Template:Category_interwiki/preload', 'relative') .. '| /doc] subpage, which is not protected.' )' <br/>' } )() end function p.main(frame, page) args, page = p:init(frame, page) local output = mw.html.create'div' :attr{role = 'note'} :addClass'metadata plainlinks asbox stub' :tag'table' :attr{role = 'presentation'} :tag'tr' :addClass'noresize' :node((args.icon or args.image) and mw.html.create'td' :wikitext(args.icon or ('[[File:%s|%spx|alt=%s]]'):format( args.image or '', args.pix or '40x30', args.imagealt or 'Stub icon' )) ) :tag'td' :tag'p' :addClass'asbox-body' :wikitext( Buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space ' is a [[Wikipedia:stub|stub]]. That means it\'s damn short, yo; you should probably go [', page:fullUrl('action=edit', 'relative'), ' do something about it].' ) :done() :node(args.note and mw.html.create() :tag'p' :addClass'asbox-note' :wikitext(args.note) :done() ) :allDone() :node(args.name and require'Module:Navbar'._navbar{ args.name, mini = 'yes', } ) --[[ Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories. Articles using the template do not need a sort key since they have unique names. When p.demo equals 'doc', the demo stub categories will appear as those for a stub template. Otherwise, any non-nil p.demo will emulate article space categories (plus any error cats unless set to 'art') ]] if page.namespace == 0 then -- Main namespace category'All stub articles' catStub() elseif p.demo then if p.demo ~= 'doc' then catStub() end --Unless p.demo is set to 'art', it will also include error categories normally only shown on --the template but not in the article. The elseif after namespace == 0 means demo cats will never show in article space. p.demodoc = p.demo ~= 'art' and p.templatepage(frame, page) output = mw.html.create() :node(output) :tag'small':wikitext( 'Demo categories: ', (category{done = true}:gsub('(%[%[)(Category:)([^|%]]-)(%|)', '%1%2%3|%2%3%4'):gsub('(%[%[)(Category:)', '%1:%2')) ):done() :wikitext(p.demo == 'doc' and p.demodoc or nil) else --Checks for valid name; emulates original template's check using {{FULLPAGENAME:{{{name|}}}}} local normalizedName = mw.title.new(args.name or '') if normalizedName and normalizedName.fullText == page.fullText then output = mw.html.create():node(output):wikitext(p.templatepage(frame, page)) elseif not page.isSubpage and page.namespace == 10 then-- Template namespace and not a subpage category{{k = args.name and 'E' or 'W', t = page.text}} end end return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(output:wikitext(not p.demo and category{done = true} or nil)) end return p bda15b055d689d295becb046cee7eaba30dd7ee0 Module:Buffer 828 43 91 90 2024-04-03T17:31:00Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Buffer]] Scribunto text/plain --[[============================= This Module was written by Alexander Zhikun He, also known as, User:Codehydro on the English Wikipedia All methods were developed independently and any resemblance to other string buffer libraries would be coincidental. Furthermore, many methods will not work when compiled by standard Lua libraries as they depend on behaviors unique to the MediaMiki Scribunto mod, which, for example, has a getmetatable() method that always returns nil on non-tables. https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual Source code comments may be thin at some points because they are intended to be supplemented by the documentation page: https://en.wikipedia.org/wiki/Module:Buffer/doc Licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License https://en.wikipedia.org/wiki/Module:Buffer https://en.wikipedia.org/wiki/User:Codehydro =============================--]] local function Valid(v)--type validation if v and v~=true then--reject nil/boolean; faster than 2 type() comparisons local str = tostring(v)--functions not filtered since unlikely passed by accident (Scribunto does not have userdata/thread types) if str~=v and str=='table' then return rawget(v, 1) and table.concat(v) end--tostring(string-type) returns same ref; same refs compare faster than type() if str~='' then return str end--numbers are coerced to string per table.concat op; appending in string form saves ops on repeat concat end end local noOp, MBpairs = function()end do local iMap, vMap, oMap, pIter, pOther, pFast, Next--Map local function init()--init = noOp after first run function Next(t) return next, t end--slightly faster to do this than to use select() function pIter(t, k) k = (iMap[t] or MBpairs(t, true) and iMap[t])[not k and 1 or vMap[t][k]] return k, t[k] end--don't use rawget; accepting unmapped tables does not measurably affect performance. function pOther(t, k) k = (oMap[t] or MBpairs(t, true) and oMap[t])[nil==k and 1 or vMap[t][k]] return k, t[k] end--comparison to nil because false is a valid key function pFast(t, k) k = not k and 1 or k < (vMap[t] or #t) and k + 1 or nil return k, t[k] end--mapless iterator; almost as fast as native ipairs; slight performance penalty when length not cached --k and k < (vMap[t] or #t) and k + 1 or not k and 1 or nil return k, t[k] end--mapless iterator; almost as fast as native ipairs; slight performance penalty when length not cached local mk = {__mode = 'k'}--use mode 'k'; found that mode 'kv' sometimes garbage collects maps mid-loop (may not error because iterators auto re-map, but that's expensive) init, iMap, vMap, oMap = noOp, setmetatable({}, mk), setmetatable({}, mk), setmetatable({}, mk)--iMap is numeric keys, oMap is non-numeric keys, and vMap points to next key end function MBpairs(t, ...)--pairs always iterates in order local iter, ex = ... iter = iter==init()--nil if iter and not oMap[t] and ex==nil and rawget(t, 1)~=nil and next(t, #t)==nil then--while possible to miss keys, more thorough check would negate the benefit of pFast vMap[t] = #t return pFast, t, nil elseif ... or not vMap[t] or select('#', ...)~=1 then local ti, tn, to, n = {}, {}, {}, #t--reduces table lookups iMap[t], vMap[t], oMap[t] = ti, tn, to for k = 1, n do ti[k], tn[k] = k, k + 1 end--stage one avoids number type checking op in stage two for most numeric keys for k in (ex or Next)(t) do if not tn[k] then table.insert(tonumber(k)~=k and to or ti, k) end end if #ti~=n then table.sort(ti) for k = 1, #ti do tn[ti[k]] = k + 1 end--somewhat wasteful, but trying to avoid overwriting can be even more expensive end for k = 1, #to do tn[to[k]] = k + 1 end end return iter and pIter or oMap[t] and pOther or noOp, t--noOp for mapless end end local parent, rawkey, spec do--new scope for variables not reused outside (reduces number of var names that need to checked outside of scope) local mkv = {__mode='kv', __call=function(t,k,v)t[k]=v return k end}--shared meta for Buffer parent property, raw mode, and specialized functions parent, rawkey, spec = setmetatable({}, mkv), setmetatable({}, mkv), setmetatable({}, mkv)--shared meta less memory end local MB, MBi, MBmix, buffHTML, gfuncs, noCache, Element do--minimize number of locals per scope to reduce time spent sifting through irrelevant variable names local _stream do local stream--keep stream near top of scope local function init(f)--init = noOp after first run local function each(self, ...) for k = 1, select('#', ...) do k = Valid(select(k, ...))--slightly faster than table.insert(self, (Valid(select(k, ...)))) if k then table.insert(self, k) end end return self end init, stream, _stream = noOp, { __call = function(t, v) v = v and Valid(v) return v and table.insert(t, v) or t end,--last_concat cleared before entering stream mode __index = function(t, i) return i=='each' and each or MB.__index(t, i) and setmetatable(t, MB)[i] end,--no table look up minimizes resources to retrieve the only stream function __tostring = function(t) return setmetatable(t, MB)() end } for k, v in next, MB do stream[k] = stream[k] or v end setmetatable(stream, getmetatable(MB)) end function _stream(self, ...) self.last_concat = init() return setmetatable(self, stream):each(...) end end local function isMBfunc(Buffer, s, ...)--helper for :getParent()-like methods (including getBuffer which does not return a parent) return s and (select('#', ...)==0 and--eventually should figure out to make this work for :getHTML which is very similar (not rawkey[s] and tostring(s):match'^_.*' and MB.__index(Buffer, s) and MB.__index(Buffer, s)(Buffer) or MBmix(Buffer, s))--unprefixed function names append as a string or assert(MB.__index(Buffer, s), ('" %s " does not match any available Module:Buffer function'):format(s))(Buffer, ...)--getParent is a one-way trip so one-time assert not expensive ) or Buffer end local function MBselect(n, ...)--helper for :_out and :_str local n, seps = n - 1, {select(2, ...)} if type(seps[n])=='table' then if buffHTML and rawget(seps[n], buffHTML) then return ... end setmetatable(seps, {__index = setmetatable(seps[n], {__index = function(t) return rawget(t, 1) end})})[n] = nil end return ..., seps end local _inHTML do local lastBuffer, lastHTML local function init(...)--init replaced and new version called on return local create, mwFunc = mw.html.create do local mwHTMLmeta = getmetatable(create()) buffHTML, mwFunc, _inHTML = setmetatable(mw.clone(mwHTMLmeta), getmetatable(MB)), mwHTMLmeta.__index--buffHTML declared near top of module; remove _inHTML from outer scope function init(nodes, ...) local name, args, tag = select(... and type(...)=='table' and 1 or 2, nil, ...) tag = create(Valid(name), args) if nodes then table.insert(nodes, tag.parent and tag or rawset(tag, 'parent', parent[nodes])) end if args then local a, b = args.selfClosing, args.parent args.selfClosing, args.parent = nil if next(args) then Element._add(parent(tag.nodes, tag), args) end args.selfClosing, args.parent = a, b--in case args is reused end return tag end for k, v in next, {[mw] = mwHTMLmeta, __call = function(h, v) return MBmix(spec[h.nodes] and h.nodes or spec(setmetatable(parent(h.nodes, h), MB), Element), v) end, __concat = false,--false means take from MB __eq = false } do buffHTML[k] = v or MB[k] end end local nonSelf, BHi = {tag=true,done=true,allDone=true}, buffHTML.__index do local g g = {__index = function(t, i) if gfuncs and gfuncs[i] then g.__index, gfuncs = gfuncs return g.__index[i] end end} setmetatable(nonSelf, g) setmetatable(BHi, g) end for k in next, nonSelf do--any HTML objects returned by these funcs will be granted Module:Buffer enhancements local func = mwFunc[k] BHi[k] = function(t, ...) local HTML = func(t, ...) return parent[HTML] and HTML or setmetatable(parent(HTML, t), buffHTML) end end do local function joinNode(HTML, sep) local nodes, join = HTML.nodes if noCache and rawkey[sep] or Valid(sep) then join, HTML.nodes = tostring(rawset(HTML, 'nodes', {MB.__call(nodes, sep)})), nodes end return join or tostring(HTML) end for k, v in next, { getParent = function(HTML, ...) lastHTML = HTML return MBi.getParent(HTML:allDone(), ...) end,--return to Buffer that created the HTML tree getBuffer = function(HTML, ...) lastHTML = HTML return isMBfunc(lastBuffer, ...) end,--return to last used killParent = function(HTML, ...) MBi.killParent(HTML:allDone(), ...) return HTML end, _out = function(HTML, ...) if ...==0 then MBi._out(HTML.nodes, ...) return HTML end lastHTML, HTML = HTML, HTML:allDone() local n, ops, seps = select('#', ...) if n > 1 then local ops, seps = MBselect(n, ...) return parent[HTML]:_in(joinNode(HTML, rawget(seps, 0))):_out(ops, rawset(seps, buffHTML, true)) end return parent[HTML]:_(joinNode(HTML, ...)) end, _str = function(HTML, ...)--does not set lastHTML if ...==0 then return joinNode(HTML, select(2, ...)) end--passing 0 strings without calling allDone() local HTML, n = HTML:allDone(), select('#', ...) if n > 1 then local ops, seps = MBselect(n, ...) return parent[HTML]:_in(joinNode(HTML, rawget(seps, 1))):_str(ops, rawset(seps, buffHTML, true)) end return joinNode(HTML, ...) end, _parent = function(HTML, ...) table.insert(HTML.nodes, parent[HTML:allDone()]:_str(...)) return HTML end } do BHi[k] = v end end do local htmlArg, skip, outFuncs = {parent=true,selfClosing=true,tagName=true}, {} do local out local function func(nodes, ...) return out(parent[nodes], ...) end outFuncs = setmetatable({ tag = function(nodes, ...) return parent(setmetatable(init(nodes, ...), buffHTML), parent[nodes]) end, done = function(b, ops) b = parent[b] while b.parent and ops~=0 do b, ops = b.parent, ops and ops - 1 or 0 end return b end }, {__index = function(nodes, i) if rawget(BHi, i) then out = BHi[i] return func end--rawget to exclude globals end}) end Element = { _add = function(nodes, t) for k, v in MBpairs(t), t, skip[t] do (v~=true and MBmix or noOp)(nodes, v) end local HTML = parent[nodes] for k, v in MBpairs(t, false) do if htmlArg[k] then HTML[k] = v elseif v and v~=true then if nonSelf[k] then if k=='tag' then if type(v)=='table' then skip[v], k = 1, rawset(create(Valid(v[1])), 'parent', HTML) Element._add(spec(parent(k.nodes, k, table.insert(nodes, k)), Element), v) if k.selfClosing then k.nodes = nil else spec[k.nodes], parent[k.nodes] = nil end--free memory/reduce clutter; parent ref will auto-unset when k.nodes is nil if not k.tagName then k.styles, k.attributes = nil end else table.insert(nodes, create(v)) end elseif mwFunc[k] then if k=='done' and tonumber(v)~=v and v[1] and tonumber(v[1])==v[1] then skip[v] = 1 end MBmix(outFuncs[k](nodes, skip[v] and v[1]).nodes, v) elseif v[1] or v[2] then k = MBi[k](nodes, unpack(v, 1, rawset(skip, v, k=='_B' and 1 or 2)[v])) Element._add(getmetatable(k) and rawget(k, 'nodes') or k, v)--if k is not a table, then v should not contain any extra keys or this may error. else MBi[k](nodes, v) end--k probably == '_G' or '_R' elseif mwFunc[k] then if type(v)~='table' or rawget(v, 'nodes') then mwFunc[k](HTML, v) else local css = k=='css' for x, y in MBpairs(v, true) do (y and y~=true and mwFunc[k] or noOp)(HTML, css and x:gsub('_', '-') or x, y) end--iterate non-numbers first for _, y in MBpairs(v, nil) do (y and y~=true and mwFunc[k] or noOp)(HTML, y) end--don't bother with gsub since text must be quoted anyhow end elseif rawget(Element, k) or rawget(MBi, k) then if tonumber(v)==v or v[1]==nil or getmetatable(v) then (Element[k] or MBi[k])(nodes, v)--v is probably string-able object, or a table to be handled by :_all else (Element[k] or MBi[k])(nodes, unpack(v, 1, table.maxn(v))) end--v is definately a table else mwFunc.css(HTML, k:gsub('_', '-', 1), tostring(v)) end--oddly enough, :_add clocked its fastest runtime after adding auto-gsub as a feature skip[v] = nil end end return nodes end } local tempMeta = {mode='v', copy={styles=true,attributes=true}} function tempMeta.__index(t, i) return tempMeta.copy[i] and rawset(t, i, MBi._cc(false, 0, t.orig[i]))[i] or t.orig[i] end rawkey[setmetatable(Element, {__index = outFuncs, __concat=function(Element, v) return setmetatable({nodes=spec({}, Element),orig=parent[v]}, tempMeta) end})] = math.huge end function MBi:getHTML(...) lastBuffer = self if ... then if select('#', ...)==1 then return not rawkey[s] and tostring(...):match'^_' and BHi[...] and BHi[...](lastHTML) or lastHTML(...) else return assert(BHi[...], ('" %s " does not match any mw.html or Buffer-mw.html function'):format(tostring(...)))(lastHTML, select(2, ...)) end end return lastHTML end function MBi:_html(...) return MBi._(self, lastHTML, select(spec[self]==Element and select('#', ...)==0 and 1 or 2, true, ...)) end return init(...) end function _inHTML(self, ...) local HTML = init(nil, ...) if HTML.selfClosing and spec[self]==Element then self.last_concat = table.insert(self, HTML) return self end lastBuffer, lastHTML = self, setmetatable(parent(HTML, self), buffHTML)--set after 'args' table processed by :_add return HTML end end local _var, unbuild do local prev, rebuild local function init(...)--init replaced before return local function pick(b, v) return b and table.insert(b, v) or v end local function c(a, num) return rawset(a.a or a, 0, a[0] and a[0] + a.c or num and a[1] or a[1]:byte())[0] end local same, build, alt = {__tostring = function(a, b) return a.a[0] and pick(b, a.a.string and string.char(a.a[0]) or a.a.table and a.a[1][a.a[0]] or a.a[0]) end}, { __index = {c = 1}, __tostring = function(t) return t:_build() end, table = function(a, b) local i = next(a[1], a[0]) or a[0]==#a[1] and next(a[1]) return pick(b, rawset(a.a or a, 0, i)[1][i]) end,--change rate (a.c) ignored since users control the table's contents number = function(a, b) return pick(b, c(a, true)) end, string = function(a, b) return pick(b, string.char(c(a))) end }, {__index = function(a, i) return a.a[i] end, __tostring = function(a, b) return (rawget(a, 0) and a[0]==tostring(a[0]) and rawset(a, 0, a[0]:byte()) or a).a._build(a, b) end} local function shift(t, c) t[0] = t[0] and t[0] + c or t:_build() and t[0] - t.c + c if t.table then t[0] = (t[0] - 1) % #t[1] + 1 end end function rebuild(...) local v, c = ... if v or select('#', ...)==0 then if v and not c then return prev end local meta, c = select(v and 1 or 3, alt, c, same, 0) return setmetatable({a = prev, _build = meta.__tostring, c = c}, meta) elseif v==nil then--no-op elseif c then shift(prev, c)--v == false else prev:_build() end end init, noCache = function(v, c) prev = setmetatable({v, c = c, _build = build[type(v)] or v, [type(v)] = true, alt = {}}, build) return prev end, true return init(...) end function unbuild(sep) for k, v in MBpairs(sep, nil) do k = getmetatable(v) if k and (k==build or k==alt) then shift(v.a or v, -v.c) end end end function _var(self, ...) local obj if ... and ...~=true then obj = init(...) elseif prev then if ...~=false then obj = rebuild(...) else rebuild(...) end end return obj and MBi._(self, obj, nil, true) or self end end local lib; MBi = setmetatable({stream = _stream, _inHTML = _inHTML, _var = _var, _ = function(self, v, ...) local at, raw = select(select('#', ...)==1 and ...==true and 1 or 2, nil, ...) if raw then rawkey[self] = math.huge else v = Valid(v) end if v or raw then if at or rawkey[self] then raw = #self end--if length increases by more than one after table.insert, then set rawkey[self] = math.huge; rawkey[self] may be equal to a previous 'at' at, self.last_concat = at and (tonumber(at)~=at and raw + at or at) table.insert(self, select(at and 1 or 2, at, v)) if at and at < 0 or raw and #self - raw > 1 then rawkey[self] = math.huge elseif at and #self==raw then rawkey[self] = rawkey[self] and math.max(rawkey[self], at) or at end end--above line looks bizarre because one table.insert op may make length jump from 0 to 8: local wtf={[2]=2,[4]=4,[8]=8}mw.log(#wtf,table.insert(wtf,1),#wtf) return self end, _nil = function(self, at, ...) if ...~=true and ...~=false then--faster than type(...) ~= 'boolean' if not at or at=='0' then self[#self] = ... if ... then rawkey[self] = math.huge end else local n, v = tonumber(at), ... if n~=at then if n then n = #self + at elseif at~=true and select('#', ...)==0 then v, n = at, #self end end if n then if v==nil and n > 0 then table.remove(self, n) else self[math.floor(n)], rawkey[self] = v, math.huge end--floor position for consistency with Table library end end self.last_concat = nil end return self end, _all = function(self, t, valKey) for k, v in MBpairs(t) do MBmix(self, v, valKey) end for k, v in valKey and MBpairs(t, false) or noOp, t do if tonumber(v) then MBi._(self, k, v)--self not always a buffer elseif rawget(MBi, k) and v and v~=true then if v[1]==nil or getmetatable(v) then MBi[k](self, v) else MBi[k](self, unpack(v, 1, table.maxn(v))) end end end return self end, _str = function(t, ...) local n = select('#', ...) if n > 1 then local k, ops, seps, r = 2, MBselect(n, ...) r = MB(t(seps[1])) while parent[t] and ops > 1 and r:_(parent[t](seps[k]), 1) do t, k, ops = parent[t], k + 1, ops - 1 end return table.concat(r, seps[k] or nil) end return MB.__call(t, ...) end, _in = function (self, ...) return parent(MB(...), self) end, _out = function(t, ...) if ...==0 then return parent(t, parent[t], MBi._cc(t, t, MB.__call(t, (select(2, ...))), getmetatable(t))) end--love how :_cc needed nothing new to implement this *self pat on back* local n = select('#', ...) if n > 1 then local k, ops, seps = 1, MBselect(n, ...) while parent[t] and ops > 0 do t, k, ops = parent[t]:_(t(seps[k])), k + 1, ops - 1 end elseif parent[t] then return parent[t]:_(t(...)) end return t end, _cc = function(self, clear, copy, meta) if clear then if rawequal(clear, copy) then return self, spec[MBi._cc] and setmetatable(spec[MBi._cc], MB)--rawequal to avoid re-string via __eq in case both are different Buffer objects elseif copy==true then copy = self end if clear~=0 then assert(type(clear)=='table', debug.traceback('Buffer:_cc can only "clear" tables. Did you forget to call with a colon?', 2))--errors can be hard to trace without this for k in self and next or noOp, clear do rawset(clear, k, nil) end else return MBi._cc(false, {unpack(copy)}, copy) end--copy length w/o empty strings; recursion to avoid self = false causing garbage collection (non-weak child may exist) if self==false or copy and type(copy)=='table' then--self==false means copy is a table (saves a type op for recursive calls) meta = meta or getmetatable(copy) if self and #copy > 1 then--preserves length with empty strings; developed from studying http://www.lua.org/source/5.1/ltable.c.html local n, null, i, e = #copy, {}, math.ldexp(2, select(2, math.frexp(#copy)) - 2) e, spec[MBi._cc], parent[null] = i - 1, null, clear for k = 1, e do table.insert(clear, false) end while i<=n do table.insert(clear, i, '') i, null[i] = i + math.ldexp(2, select(2, math.frexp(n - i)) - 2), '' end for k = 1, e do rawset(clear, k, nil) end end for k, v in next, copy do rawset(clear, k, type(v)=='table' and MBi._cc(false, 0, v) or v) end elseif copy then rawset(clear, 1, (Valid(copy))) end rawkey[setmetatable(clear, meta)], parent[clear] = rawkey[copy], parent[copy] end return self and rawset(self, 'last_concat', nil) or clear end, _parent = function(self, ...) return parent[self] and MBi._(self, parent[self]:_str(...)) or self end, getParent = function(self, ...) return isMBfunc(parent[self] or parent[parent(self, setmetatable({}, MB))], ...) end, killParent = function(self, ...) return parent[self] and isMBfunc(parent[self], ...) and parent(self) or self end, _build = function(self, t) table.insert(t, self()) end,--for compatibility with mw.html:node() last_concat = false--prevent library check }, {__index = function(t, i)--import string, mw.text, and mw.ustring libraries on an as-needed basis local func = string[i] or mw.text[i] or mw.ustring[i] or type(i)=='string' and mw.ustring[i:match'^u(.+)'] if func then lib = lib or function (s, f, ...) if parent[s] and next(s)==nil then return s:_((f(tostring(parent[Element and (spec[s]==Element and s:allDone() or spec[parent[s]]==Element and parent[s]) or s]), ...))) end return f(tostring(s), ...)--not using ternary/logical operators here to allow multiple return values end return rawset(t, i, i:match'^u?gsub' and function(self, p, r, ...)return lib(self, func, p, r or '', ...)end--Why are ugsub/gsub special? because empty strings are against my religion! or function(self, ...)return lib(self, func, ...)end)[i] end end}) end function MBmix(t, v, ...) return v and ((type(v)~='table' or getmetatable(v)) and MBi._(t, v) or (select('#', ...)==0 and spec[t] and spec[t]._add or MBi._all)(t, v, ...)) or t end--:_all always passes two args local _G, new_G = _G--localize _G for console testing (console _G ~= module _G) return setmetatable({__index = function(t, i) return spec[t] and spec[t][i] or MBi[i] end, __call = function(t, ...) local rawsep, sep, i, j, raw = noCache and rawkey[...] and ..., ... if i or j or rawsep or Valid(sep) then raw, sep, i, j = rawkey[spec[t]] or rawkey[t], rawsep or Valid(sep), i and (i~=tonumber(i) and i + #t or i), j and (j~=tonumber(j) and j + #t or j) if rawsep or raw and (raw>=(j or #t) or i < 1) then raw, i, j = {}, i and math.floor(i), j and math.floor(j)--floor for consistency with table.concat(t, sep, i, j), which ignores decimals raw.lc, t.last_concat = t.last_concat--temporarily unset last_concat to prevent disqualification from mapless iteration for k, v in MBpairs(t) do if raw[1] or not i or k>=i then if j and k > j then break end if raw.s then raw.s = table.insert(raw, tostring(sep)) end--if sep contains v and v is a Buffer-variable, sep must be strung before v k = Valid(v) if k then raw.s = rawsep or sep and raw[1] and table.insert(raw, sep) table.insert(raw, k) end end end if rawsep and not raw.s then raw[#raw] = unbuild(sep) end--unbuild rawsep if final index in t was invalid t.last_concat = raw.lc return table.concat(raw) end return table.concat(t, sep, i and math.max(i, 1), j and math.min(j, #t)) end return MB.__tostring(t) end, __tostring = function(t) if t.last_concat then return t.last_concat end local r = rawkey[spec[t]] or rawkey[t] r = table.concat(r and r>=#t and MBi._all({}, t) or t) return (noCache or rawset(t, 'last_concat', r)) and r end, __concat = function(a, b) if buffHTML then for k = 1, 2 do local v = select(k, a, b)--faster than for k, v in pairs{a, b} do if v and spec[v] and spec[v]==Element then if parent[v].selfClosing then if rawequal(a, b) then return (not noCache or parent[v].tagName) and v:_str(0):rep(2) or v:_str(0)..v:_str(0) end--rawequal avoids premature tostring of Buffer:_var objects; b, a = select(k, b, parent[v], a) else local temp = Element .. v --helper method; returns a mirror of parent[v] MBmix(MBmix(parent(temp.nodes, temp), a), k==1 and spec[b]==Element and parent[b] or b) return buffHTML.__tostring(setmetatable(temp, {__index=parent[v], __mode='v'}))--switch from tempMeta to avoid MBi._cc op of styles/attributes end end end end return table.concat(MBmix(MBmix({}, a), b)) end, __pairs = MBpairs, __ipairs = MBpairs, __eq = function(a, b) return tostring(a)==tostring(b) end--avoid a==b in this module; use rawequal(a,b) when they may be different Buffers (premature tostring waste ops and is bad for Buffer:_var) }, {__tostring = function()return''end, __call = function(self, ...) MB = MB or self if new_G then if ... and _G and ...==_G then new_G = ... end elseif ... and (...==_G or type(...)=='table' and (...)._G==...) then local Nil, mG = {}, (...):getmetatable() or (...):setmetatable{}:getmetatable() new_G, _G, gfuncs = ..., ..., {--gfuncs stored for Buffer:_inHTML; new_G is a is a Module:Buffer local declared just before the final return statement. _G = function(self, i, ...) local X, save = rawget(new_G, i), select('#', ...)==0 and self or ... if i and i~=true and not (X and save and rawequal(X, save)) and rawset(new_G, i, save) and (X~=nil or save==nil and new_G[i]~=nil) then--rawequal in case X is another buffer local mG = getmetatable(new_G) or {__call=mG.__call} if mG.__index then pcall(rawset, mG.__index, i, X) else mG.__index = setmetatable(new_G, mG) and {[i] = X} end end return self, ...--avoiding __eq with rawequal(self,save) is overkill since buffers can self-save without being passed as save end, _R = function(self, i, v, m) if i~='new_G' then if i and i~=true then rawset(new_G, i , v) end elseif not v or v==true or v._G~=_G then new_G = setmetatable(v~=true and v or {}, {__call = mG.__call, __index = v~=true and m~=true and (m or new_G) or nil}) else new_G, (not m and (m~=nil or v==new_G) and Nil or getmetatable(v)).__index = v, m~=true and (m or new_G) or nil end--setting Nil.__index is noOp return self end, _2 = function(self, ...) if new_G[...]~=nil then return new_G[...] end--higher priority so Buffer:_G('new_G', ...) can prevent an overwrite if ...=='new_G' then return rawset((select('#', ...)~=1 and MBi._R(new_G, ...) or new_G), '_G', _G) end return select(select('#', ...)==1 and 1 or 2, self:_G(...))--return only one value; 'return select(2, self:_G(...)) or self' doesn't work for returning nil end, _B = function(self, v) return v or v==nil and Nil end } for k, v in next, gfuncs do MBi[k] = v end setmetatable(Nil,{__concat=MB.__concat,__newindex=noOp,__call=noOp,__tostring=noOp,__metatable=MB,__index=setmetatable({_B=MBi._B,_=function()return Nil end,last_concat=''}, {__index=function(t,i)return (MBi[i] or i and not tonumber(i)) and t._ or nil end})}) function mG.__call(G, k, ...) return (k._G or G.type(k)=='table') and (G.select('#', ...)~=1 and G.rawset(k, ...) or G:rawset(..., k) and k) or G:rawset(k, (...)) and ... end end local new = setmetatable({}, self) if ... and (...)==new_G then return select(2, ...) and MBmix(new:_G((select(2, ...))), select(3, ...)) or new end return ... and MBi._(new, ...) or new end, __index = function(t, i) MB = MB or t return MBi[i] and function(...) return MBi[i](setmetatable({}, t), select(...==t and 2 or 1,...)) end end }) a531c35e1366f84755b75caab181cd45e5330bbe Module:Documentation 828 8 93 21 2024-04-03T17:31:01Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Documentation]] Scribunto text/plain -- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs local messageBox = require('Module:Message box') -- Get the config table. local cfg = mw.loadData('Module:Documentation/config') local i18n = mw.loadData('Module:Documentation/i18n') local p = {} -- Often-used functions. local ugsub = mw.ustring.gsub ---------------------------------------------------------------------------- -- Helper functions -- -- These are defined as local functions, but are made available in the p -- table for testing purposes. ---------------------------------------------------------------------------- local function message(cfgKey, valArray, expectType) --[[ -- Gets a message from the cfg table and formats it if appropriate. -- The function raises an error if the value from the cfg table is not -- of the type expectType. The default type for expectType is 'string'. -- If the table valArray is present, strings such as $1, $2 etc. in the -- message are substituted with values from the table keys [1], [2] etc. -- For example, if the message "foo-message" had the value 'Foo $2 bar $1.', -- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz." --]] local msg = cfg[cfgKey] expectType = expectType or 'string' if type(msg) ~= expectType then error(require('Module:TNT').format('I18n/Documentation', 'cfg-error-msg-type', cfgKey, expectType, type(msg)), 2) end if not valArray then return msg end local function getMessageVal(match) match = tonumber(match) return valArray[match] or error(require('Module:TNT').format('I18n/Documentation', 'cfg-error-msg-empty', '$' .. match, cfgKey), 4) end local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal) return ret end p.message = message local function makeWikilink(page, display) if display then return mw.ustring.format('[[%s|%s]]', page, display) else return mw.ustring.format('[[%s]]', page) end end p.makeWikilink = makeWikilink local function makeCategoryLink(cat, sort) local catns = mw.site.namespaces[14].name return makeWikilink(catns .. ':' .. cat, sort) end p.makeCategoryLink = makeCategoryLink local function makeUrlLink(url, display) return mw.ustring.format('[%s %s]', url, display) end p.makeUrlLink = makeUrlLink local function makeToolbar(...) local ret = {} local lim = select('#', ...) if lim < 1 then return nil end for i = 1, lim do ret[#ret + 1] = select(i, ...) end return '<small style="font-style: normal;">(' .. table.concat(ret, ' &#124; ') .. ')</small>' end p.makeToolbar = makeToolbar ---------------------------------------------------------------------------- -- Argument processing ---------------------------------------------------------------------------- local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame, { valueFunc = function (key, value) if type(value) == 'string' then value = value:match('^%s*(.-)%s*$') -- Remove whitespace. if key == 'heading' or value ~= '' then return value else return nil end else return value end end }) return p[funcName](args) end end ---------------------------------------------------------------------------- -- Load TemplateStyles ---------------------------------------------------------------------------- p.main = function(frame) local parent = frame.getParent(frame) local output = p._main(parent.args) return frame:extensionTag{ name='templatestyles', args = { src= message('templatestyles-scr') } } .. output end ---------------------------------------------------------------------------- -- Main function ---------------------------------------------------------------------------- function p._main(args) --[[ -- This function defines logic flow for the module. -- @args - table of arguments passed by the user -- -- Messages: -- 'main-div-id' --> 'template-documentation' -- 'main-div-classes' --> 'template-documentation iezoomfix' --]] local env = p.getEnvironment(args) local root = mw.html.create() root :wikitext(p._getModuleWikitext(args, env)) :wikitext(p.protectionTemplate(env)) :wikitext(p.sandboxNotice(args, env)) -- This div tag is from {{documentation/start box}}, but moving it here -- so that we don't have to worry about unclosed tags. :tag('div') :attr('id', message('main-div-id')) :addClass(message('main-div-class')) :wikitext(p._startBox(args, env)) :wikitext(p._content(args, env)) :done() :wikitext(p._endBox(args, env)) :wikitext(p.addTrackingCategories(env)) return tostring(root) end ---------------------------------------------------------------------------- -- Environment settings ---------------------------------------------------------------------------- function p.getEnvironment(args) --[[ -- Returns a table with information about the environment, including title objects and other namespace- or -- path-related data. -- @args - table of arguments passed by the user -- -- Title objects include: -- env.title - the page we are making documentation for (usually the current title) -- env.templateTitle - the template (or module, file, etc.) -- env.docTitle - the /doc subpage. -- env.sandboxTitle - the /sandbox subpage. -- env.testcasesTitle - the /testcases subpage. -- env.printTitle - the print version of the template, located at the /Print subpage. -- -- Data includes: -- env.protectionLevels - the protection levels table of the title object. -- env.subjectSpace - the number of the title's subject namespace. -- env.docSpace - the number of the namespace the title puts its documentation in. -- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace. -- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template. -- -- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value -- returned will be nil. --]] local env, envFuncs = {}, {} -- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value -- returned by that function is memoized in the env table so that we don't call any of the functions -- more than once. (Nils won't be memoized.) setmetatable(env, { __index = function (t, key) local envFunc = envFuncs[key] if envFunc then local success, val = pcall(envFunc) if success then env[key] = val -- Memoise the value. return val end end return nil end }) function envFuncs.title() -- The title object for the current page, or a test page passed with args.page. local title local titleArg = args.page if titleArg then title = mw.title.new(titleArg) else title = mw.title.getCurrentTitle() end return title end function envFuncs.templateTitle() --[[ -- The template (or module, etc.) title object. -- Messages: -- 'sandbox-subpage' --> 'sandbox' -- 'testcases-subpage' --> 'testcases' --]] local subjectSpace = env.subjectSpace local title = env.title local subpage = title.subpageText if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then return mw.title.makeTitle(subjectSpace, title.baseText) else return mw.title.makeTitle(subjectSpace, title.text) end end function envFuncs.docTitle() --[[ -- Title object of the /doc subpage. -- Messages: -- 'doc-subpage' --> 'doc' --]] local title = env.title local docname = args[1] -- User-specified doc page. local docpage if docname then docpage = docname else docpage = env.docpageBase .. '/' .. message('doc-subpage') end return mw.title.new(docpage) end function envFuncs.sandboxTitle() --[[ -- Title object for the /sandbox subpage. -- Messages: -- 'sandbox-subpage' --> 'sandbox' --]] return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage')) end function envFuncs.testcasesTitle() --[[ -- Title object for the /testcases subpage. -- Messages: -- 'testcases-subpage' --> 'testcases' --]] return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage')) end function envFuncs.printTitle() --[[ -- Title object for the /Print subpage. -- Messages: -- 'print-subpage' --> 'Print' --]] return env.templateTitle:subPageTitle(message('print-subpage')) end function envFuncs.protectionLevels() -- The protection levels table of the title object. return env.title.protectionLevels end function envFuncs.subjectSpace() -- The subject namespace number. return mw.site.namespaces[env.title.namespace].subject.id end function envFuncs.docSpace() -- The documentation namespace number. For most namespaces this is the same as the -- subject namespace. However, pages in the Article, File, MediaWiki or Category -- namespaces must have their /doc, /sandbox and /testcases pages in talk space. local subjectSpace = env.subjectSpace if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then return subjectSpace + 1 else return subjectSpace end end function envFuncs.docpageBase() -- The base page of the /doc, /sandbox, and /testcases subpages. -- For some namespaces this is the talk page, rather than the template page. local templateTitle = env.templateTitle local docSpace = env.docSpace local docSpaceText = mw.site.namespaces[docSpace].name -- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon. return docSpaceText .. ':' .. templateTitle.text end function envFuncs.compareUrl() -- Diff link between the sandbox and the main template using [[Special:ComparePages]]. local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle if templateTitle.exists and sandboxTitle.exists then local compareUrl = mw.uri.fullUrl( 'Special:ComparePages', {page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} ) return tostring(compareUrl) else return nil end end return env end ---------------------------------------------------------------------------- -- Auxiliary templates ---------------------------------------------------------------------------- p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext') function p._getModuleWikitext(args, env) local currentTitle = mw.title.getCurrentTitle() if currentTitle.contentModel ~= 'Scribunto' then return end pcall(require, currentTitle.prefixedText) -- if it fails, we don't care local moduleWikitext = package.loaded["Module:Module wikitext"] if moduleWikitext then return moduleWikitext.main() end end function p.sandboxNotice(args, env) --[=[ -- Generates a sandbox notice for display above sandbox pages. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-notice-image' --> '[[Image:Sandbox.svg|50px|alt=|link=]]' -- 'sandbox-notice-blurb' --> 'This is the $1 for $2.' -- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).' -- 'sandbox-notice-pagetype-template' --> '[[w:Wikipedia:Template test cases|template sandbox]] page' -- 'sandbox-notice-pagetype-module' --> '[[w:Wikipedia:Template test cases|module sandbox]] page' -- 'sandbox-notice-pagetype-other' --> 'sandbox page' -- 'sandbox-notice-compare-link-display' --> 'diff' -- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.' -- 'sandbox-notice-testcases-link-display' --> 'test cases' -- 'sandbox-category' --> 'Template sandboxes' --]=] local title = env.title local sandboxTitle = env.sandboxTitle local templateTitle = env.templateTitle local subjectSpace = env.subjectSpace if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then return nil end -- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text". local omargs = {} omargs.image = message('sandbox-notice-image') -- Get the text. We start with the opening blurb, which is something like -- "This is the template sandbox for [[Template:Foo]] (diff)." local text = '' local frame = mw.getCurrentFrame() local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed. local pagetype if subjectSpace == 10 then pagetype = message('sandbox-notice-pagetype-template') elseif subjectSpace == 828 then pagetype = message('sandbox-notice-pagetype-module') else pagetype = message('sandbox-notice-pagetype-other') end local templateLink = makeWikilink(templateTitle.prefixedText) local compareUrl = env.compareUrl if isPreviewing or not compareUrl then text = text .. message('sandbox-notice-blurb', {pagetype, templateLink}) else local compareDisplay = message('sandbox-notice-compare-link-display') local compareLink = makeUrlLink(compareUrl, compareDisplay) text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink}) end -- Get the test cases page blurb if the page exists. This is something like -- "See also the companion subpage for [[Template:Foo/testcases|test cases]]." local testcasesTitle = env.testcasesTitle if testcasesTitle and testcasesTitle.exists then if testcasesTitle.contentModel == "Scribunto" then local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink}) else local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink}) end end -- Add the sandbox to the sandbox category. text = text .. makeCategoryLink(message('sandbox-category')) omargs.text = text omargs.class = message('sandbox-class') local ret = '<div style="clear: both;"></div>' ret = ret .. messageBox.main('ombox', omargs) return ret end function p.protectionTemplate(env) -- Generates the padlock icon in the top right. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'protection-template' --> 'pp-template' -- 'protection-template-args' --> {docusage = 'yes'} local title = env.title local protectionLevels local protectionTemplate = message('protection-template') local namespace = title.namespace if not (protectionTemplate and (namespace == 10 or namespace == 828)) then -- Don't display the protection template if we are not in the template or module namespaces. return nil end protectionLevels = env.protectionLevels if not protectionLevels then return nil end local editLevels = protectionLevels.edit local moveLevels = protectionLevels.move if moveLevels and moveLevels[1] == 'sysop' or editLevels and editLevels[1] then -- The page is full-move protected, or full, template, or semi-protected. local frame = mw.getCurrentFrame() return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')} else return nil end end ---------------------------------------------------------------------------- -- Start box ---------------------------------------------------------------------------- p.startBox = makeInvokeFunc('_startBox') function p._startBox(args, env) --[[ -- This function generates the start box. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make -- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox -- which generate the box HTML. --]] env = env or p.getEnvironment(args) local links local content = args.content if not content then -- No need to include the links if the documentation is on the template page itself. local linksData = p.makeStartBoxLinksData(args, env) if linksData then links = p.renderStartBoxLinks(linksData) end end -- Generate the start box html. local data = p.makeStartBoxData(args, env, links) if data then return p.renderStartBox(data) else -- User specified no heading. return nil end end function p.makeStartBoxLinksData(args, env) --[[ -- Does initial processing of data to make the [view] [edit] [history] [purge] links. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'view-link-display' --> 'view' -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'purge-link-display' --> 'purge' -- 'file-docpage-preload' --> 'Template:Documentation/preload-filespace' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'docpage-preload' --> 'Template:Documentation/preload' -- 'create-link-display' --> 'create' --]] local subjectSpace = env.subjectSpace local title = env.title local docTitle = env.docTitle if not title or not docTitle then return nil end if docTitle.isRedirect then docTitle = docTitle.redirectTarget end local data = {} data.title = title data.docTitle = docTitle -- View, display, edit, and purge links if /doc exists. data.viewLinkDisplay = i18n['view-link-display'] data.editLinkDisplay = i18n['edit-link-display'] data.historyLinkDisplay = i18n['history-link-display'] data.purgeLinkDisplay = i18n['purge-link-display'] -- Create link if /doc doesn't exist. local preload = args.preload if not preload then if subjectSpace == 6 then -- File namespace preload = message('file-docpage-preload') elseif subjectSpace == 828 then -- Module namespace preload = message('module-preload') else preload = message('docpage-preload') end end data.preload = preload data.createLinkDisplay = i18n['create-link-display'] return data end function p.renderStartBoxLinks(data) --[[ -- Generates the [view][edit][history][purge] or [create] links from the data table. -- @data - a table of data generated by p.makeStartBoxLinksData --]] local function escapeBrackets(s) -- Escapes square brackets with HTML entities. s = s:gsub('%[', '&#91;') -- Replace square brackets with HTML entities. s = s:gsub('%]', '&#93;') return s end local ret local docTitle = data.docTitle local title = data.title if docTitle.exists then local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay) local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay) local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay) local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay) ret = '[%s] [%s] [%s] [%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink) else local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay) ret = '[%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, createLink) end return ret end function p.makeStartBoxData(args, env, links) --[=[ -- Does initial processing of data to pass to the start-box render function, p.renderStartBox. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error. -- -- Messages: -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]' -- 'template-namespace-heading' --> 'Template documentation' -- 'module-namespace-heading' --> 'Module documentation' -- 'file-namespace-heading' --> 'Summary' -- 'other-namespaces-heading' --> 'Documentation' -- 'start-box-linkclasses' --> 'mw-editsection-like plainlinks' -- 'start-box-link-id' --> 'doc_editlinks' -- 'testcases-create-link-display' --> 'create' --]=] local subjectSpace = env.subjectSpace if not subjectSpace then -- Default to an "other namespaces" namespace, so that we get at least some output -- if an error occurs. subjectSpace = 2 end local data = {} -- Heading local heading = args.heading -- Blank values are not removed. if heading == '' then -- Don't display the start box if the heading arg is defined but blank. return nil end if heading then data.heading = heading elseif subjectSpace == 10 then -- Template namespace data.heading = i18n['template-namespace-heading'] elseif subjectSpace == 828 then -- Module namespace data.heading = i18n['module-namespace-heading'] elseif subjectSpace == 6 then -- File namespace data.heading = i18n['file-namespace-heading'] else data.heading = i18n['other-namespaces-heading'] end -- Data for the [view][edit][history][purge] or [create] links. if links then data.linksClass = message('start-box-linkclasses') data.linksId = message('start-box-link-id') data.links = links end return data end function p.renderStartBox(data) -- Renders the start box html. -- @data - a table of data generated by p.makeStartBoxData. local sbox = mw.html.create('div') sbox :addClass(message('header-div-class')) :tag('div') :addClass(message('heading-div-class')) :wikitext(data.heading) local links = data.links if links then sbox :tag('div') :addClass(data.linksClass) :attr('id', data.linksId) :wikitext(links) end return tostring(sbox) end ---------------------------------------------------------------------------- -- Documentation content ---------------------------------------------------------------------------- p.content = makeInvokeFunc('_content') function p._content(args, env) -- Displays the documentation contents -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment env = env or p.getEnvironment(args) local docTitle = env.docTitle local content = args.content if not content and docTitle and docTitle.exists then content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle} end -- The line breaks below are necessary so that "=== Headings ===" at the start and end -- of docs are interpreted correctly. local cbox = mw.html.create('div') cbox :addClass(message('content-div-class')) :wikitext('\n' .. (content or '') .. '\n') return tostring(cbox) end p.contentTitle = makeInvokeFunc('_contentTitle') function p._contentTitle(args, env) env = env or p.getEnvironment(args) local docTitle = env.docTitle if not args.content and docTitle and docTitle.exists then return docTitle.prefixedText else return '' end end ---------------------------------------------------------------------------- -- End box ---------------------------------------------------------------------------- p.endBox = makeInvokeFunc('_endBox') function p._endBox(args, env) --[=[ -- This function generates the end box (also known as the link box). -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment --]=] -- Get environment data. env = env or p.getEnvironment(args) local subjectSpace = env.subjectSpace local docTitle = env.docTitle if not subjectSpace or not docTitle then return nil end -- Check whether we should output the end box at all. Add the end -- box by default if the documentation exists or if we are in the -- user, module or template namespaces. local linkBox = args['link box'] if linkBox == 'off' or not ( docTitle.exists or subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 ) then return nil end -- Assemble the footer text field. local text = '' if linkBox then text = text .. linkBox else text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]." if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then -- We are in the user, template or module namespaces. -- Add sandbox and testcases links. -- "Editors can experiment in this template's sandbox and testcases pages." text = text .. (p.makeExperimentBlurb(args, env) or '') text = text .. '<br />' if not args.content and not args[1] then -- "Please add categories to the /doc subpage." -- Don't show this message with inline docs or with an explicitly specified doc page, -- as then it is unclear where to add the categories. text = text .. (p.makeCategoriesBlurb(args, env) or '') end text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template" local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates. if printBlurb then text = text .. '<br />' .. printBlurb end end end local ebox = mw.html.create('div') ebox :addClass(message('footer-div-class')) :wikitext(text) return tostring(ebox) end function p.makeDocPageBlurb(args, env) --[=[ -- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)". -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'transcluded-from-blurb' --> -- 'The above [[w:Wikipedia:Template documentation|documentation]] -- is [[w:Wikipedia:Transclusion|transcluded]] from $1.' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'create-link-display' --> 'create' -- 'create-module-doc-blurb' --> -- 'You might want to $1 a documentation page for this [[w:Wikipedia:Lua|Scribunto module]].' --]=] local docTitle = env.docTitle if not docTitle or args.content then return nil end local ret if docTitle.exists then -- /doc exists; link to it. local docLink = makeWikilink(docTitle.prefixedText) local editUrl = docTitle:fullUrl{action = 'edit'} local editDisplay = i18n['edit-link-display'] local editLink = makeUrlLink(editUrl, editDisplay) local historyUrl = docTitle:fullUrl{action = 'history'} local historyDisplay = i18n['history-link-display'] local historyLink = makeUrlLink(historyUrl, historyDisplay) ret = message('transcluded-from-blurb', {docLink}) .. ' ' .. makeToolbar(editLink, historyLink) .. '<br />' elseif env.subjectSpace == 828 then -- /doc does not exist; ask to create it. local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')} local createDisplay = i18n['create-link-display'] local createLink = makeUrlLink(createUrl, createDisplay) ret = message('create-module-doc-blurb', {createLink}) .. '<br />' end return ret end function p.makeExperimentBlurb(args, env) --[[ -- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-link-display' --> 'sandbox' -- 'sandbox-edit-link-display' --> 'edit' -- 'compare-link-display' --> 'diff' -- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'sandbox-create-link-display' --> 'create' -- 'mirror-edit-summary' --> 'Create sandbox version of $1' -- 'mirror-link-display' --> 'mirror' -- 'mirror-link-preload' --> 'Template:Documentation/mirror' -- 'sandbox-link-display' --> 'sandbox' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display'--> 'edit' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'testcases-create-link-display' --> 'create' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display' --> 'edit' -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases' -- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases' -- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.' -- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle local testcasesTitle = env.testcasesTitle local templatePage = templateTitle.prefixedText if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then return nil end -- Make links. local sandboxLinks, testcasesLinks if sandboxTitle.exists then local sandboxPage = sandboxTitle.prefixedText local sandboxDisplay = message('sandbox-link-display') local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'} local sandboxEditDisplay = message('sandbox-edit-link-display') local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay) local compareUrl = env.compareUrl local compareLink if compareUrl then local compareDisplay = message('compare-link-display') compareLink = makeUrlLink(compareUrl, compareDisplay) end sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) else local sandboxPreload if subjectSpace == 828 then sandboxPreload = message('module-sandbox-preload') else sandboxPreload = message('template-sandbox-preload') end local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload} local sandboxCreateDisplay = message('sandbox-create-link-display') local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) local mirrorPreload = message('mirror-link-preload') local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} local mirrorDisplay = message('mirror-link-display') local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) end if testcasesTitle.exists then local testcasesPage = testcasesTitle.prefixedText local testcasesDisplay = message('testcases-link-display') local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'} local testcasesEditDisplay = message('testcases-edit-link-display') local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) else local testcasesPreload if subjectSpace == 828 then testcasesPreload = message('module-testcases-preload') else testcasesPreload = message('template-testcases-preload') end local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload} local testcasesCreateDisplay = message('testcases-create-link-display') local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink) end local messageName if subjectSpace == 828 then messageName = 'experiment-blurb-module' else messageName = 'experiment-blurb-template' end return message(messageName, {sandboxLinks, testcasesLinks}) end function p.makeCategoriesBlurb(args, env) --[[ -- Generates the text "Please add categories to the /doc subpage." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'doc-link-display' --> '/doc' -- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.' --]] local docTitle = env.docTitle if not docTitle then return nil end local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display')) return message('add-categories-blurb', {docPathLink}) end function p.makeSubpagesBlurb(args, env) --[[ -- Generates the "Subpages of this template" link. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'template-pagetype' --> 'template' -- 'module-pagetype' --> 'module' -- 'default-pagetype' --> 'page' -- 'subpages-link-display' --> 'Subpages of this $1' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle if not subjectSpace or not templateTitle then return nil end local pagetype if subjectSpace == 10 then pagetype = message('template-pagetype') elseif subjectSpace == 828 then pagetype = message('module-pagetype') else pagetype = message('default-pagetype') end local subpagesLink = makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpages-link-display', {pagetype}) ) return message('subpages-blurb', {subpagesLink}) end function p.makePrintBlurb(args, env) --[=[ -- Generates the blurb displayed when there is a print version of the template available. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'print-link-display' --> '/Print' -- 'print-blurb' --> 'A [[Help:Books/for experts#Improving the book layout|print version]]' -- .. ' of this template exists at $1.' -- .. ' If you make a change to this template, please update the print version as well.' -- 'display-print-category' --> true -- 'print-category' --> 'Templates with print versions' --]=] local printTitle = env.printTitle if not printTitle then return nil end local ret if printTitle.exists then local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display')) ret = message('print-blurb', {printLink}) local displayPrintCategory = message('display-print-category', nil, 'boolean') if displayPrintCategory then ret = ret .. makeCategoryLink(message('print-category')) end end return ret end ---------------------------------------------------------------------------- -- Tracking categories ---------------------------------------------------------------------------- function p.addTrackingCategories(env) --[[ -- Check if {{documentation}} is transcluded on a /doc or /testcases page. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'display-strange-usage-category' --> true -- 'doc-subpage' --> 'doc' -- 'testcases-subpage' --> 'testcases' -- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage' -- -- /testcases pages in the module namespace are not categorised, as they may have -- {{documentation}} transcluded automatically. --]] local title = env.title local subjectSpace = env.subjectSpace if not title or not subjectSpace then return nil end local subpage = title.subpageText local ret = '' if message('display-strange-usage-category', nil, 'boolean') and ( subpage == message('doc-subpage') or subjectSpace ~= 828 and subpage == message('testcases-subpage') ) then ret = ret .. makeCategoryLink(message('strange-usage-category')) end return ret end return p 0e23eec0d3c20c23afcd28849e240b9083dbcf88 Module:Documentation/config 828 12 95 25 2024-04-03T17:31:01Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Documentation/config]] Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- -- Configuration for Module:Documentation -- -- Here you can set the values of the parameters and messages used in Module:Documentation to -- localise it to your wiki and your language. Unless specified otherwise, values given here -- should be string values. ---------------------------------------------------------------------------------------------------- local _format = require('Module:TNT').format local function format(id) return _format('I18n/Documentation', id) end local cfg = {} -- Do not edit this line. cfg['templatestyles-scr'] = 'Module:Documentation/styles.css' ---------------------------------------------------------------------------------------------------- -- Protection template configuration ---------------------------------------------------------------------------------------------------- -- cfg['protection-template'] -- The name of the template that displays the protection icon (a padlock on enwiki). cfg['protection-template'] = 'pp-template' -- cfg['protection-reason-edit'] -- The protection reason for edit-protected templates to pass to -- [[Module:Protection banner]]. cfg['protection-reason-edit'] = 'template' --[[ -- cfg['protection-template-args'] -- Any arguments to send to the protection template. This should be a Lua table. -- For example, if the protection template is "pp-template", and the wikitext template invocation -- looks like "{{pp-template|docusage=yes}}", then this table should look like "{docusage = 'yes'}". --]] cfg['protection-template-args'] = {docusage = 'yes'} --[[ ---------------------------------------------------------------------------------------------------- -- Sandbox notice configuration -- -- On sandbox pages the module can display a template notifying users that the current page is a -- sandbox, and the location of test cases pages, etc. The module decides whether the page is a -- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the -- messages that the notices contains. ---------------------------------------------------------------------------------------------------- --]] -- cfg['sandbox-notice-image'] -- The image displayed in the sandbox notice. cfg['sandbox-notice-image'] = '[[File:Edit In Sandbox Icon - Color.svg|40px|alt=|link=]]' --[[ -- cfg['sandbox-notice-pagetype-template'] -- cfg['sandbox-notice-pagetype-module'] -- cfg['sandbox-notice-pagetype-other'] -- The page type of the sandbox page. The message that is displayed depends on the current subject -- namespace. This message is used in either cfg['sandbox-notice-blurb'] or -- cfg['sandbox-notice-diff-blurb']. --]] cfg['sandbox-notice-pagetype-template'] = format('sandbox-notice-pagetype-template') cfg['sandbox-notice-pagetype-module'] = format('sandbox-notice-pagetype-module') cfg['sandbox-notice-pagetype-other'] = format('sandbox-notice-pagetype-other') --[[ -- cfg['sandbox-notice-blurb'] -- cfg['sandbox-notice-diff-blurb'] -- cfg['sandbox-notice-diff-display'] -- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence -- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page -- type, which is either cfg['sandbox-notice-pagetype-template'], -- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what -- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between -- the sandbox and the main template. The display value of the diff link is set by -- cfg['sandbox-notice-compare-link-display']. --]] cfg['sandbox-notice-blurb'] = format('sandbox-notice-blurb') cfg['sandbox-notice-diff-blurb'] = format('sandbox-notice-diff-blurb') cfg['sandbox-notice-compare-link-display'] = format('sandbox-notice-compare-link-display') --[[ -- cfg['sandbox-notice-testcases-blurb'] -- cfg['sandbox-notice-testcases-link-display'] -- cfg['sandbox-notice-testcases-run-blurb'] -- cfg['sandbox-notice-testcases-run-link-display'] -- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit. $1 is a link to the test cases page. -- cfg['sandbox-notice-testcases-link-display'] is the display value for that link. -- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test -- cases page, and $2 is a link to the page to run it. -- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test -- cases. --]] cfg['sandbox-notice-testcases-blurb'] = format('sandbox-notice-testcases-blurb') cfg['sandbox-notice-testcases-link-display'] = format('sandbox-notice-testcases-link-display') cfg['sandbox-notice-testcases-run-blurb'] = format('sandbox-notice-testcases-run-blurb') cfg['sandbox-notice-testcases-run-link-display'] = format('sandbox-notice-testcases-run-link-display') -- cfg['sandbox-category'] -- A category to add to all template sandboxes. cfg['sandbox-category'] = 'Template sandboxes' ---------------------------------------------------------------------------------------------------- -- Start box configuration ---------------------------------------------------------------------------------------------------- -- cfg['documentation-icon-wikitext'] -- The wikitext for the icon shown at the top of the template. cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]' ---------------------------------------------------------------------------------------------------- -- Link box (end box) configuration ---------------------------------------------------------------------------------------------------- -- cfg['transcluded-from-blurb'] -- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page. cfg['transcluded-from-blurb'] = format('transcluded-from-blurb') --[[ -- cfg['create-module-doc-blurb'] -- Notice displayed in the module namespace when the documentation subpage does not exist. -- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the -- display cfg['create-link-display']. --]] cfg['create-module-doc-blurb'] = format('create-module-doc-blurb') ---------------------------------------------------------------------------------------------------- -- Experiment blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['experiment-blurb-template'] -- cfg['experiment-blurb-module'] -- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages. -- It is only shown in the template and module namespaces. With the default English settings, it -- might look like this: -- -- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. -- -- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links. -- -- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending -- on what namespace we are in. -- -- Parameters: -- -- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display']) -- -- If the sandbox doesn't exist, it is in the format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display']) -- -- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload'] -- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display'] -- loads a default edit summary of cfg['mirror-edit-summary']. -- -- $2 is a link to the test cases page. If the test cases page exists, it is in the following format: -- -- cfg['testcases-link-display'] (cfg['testcases-edit-link-display']) -- -- If the test cases page doesn't exist, it is in the format: -- -- cfg['testcases-link-display'] (cfg['testcases-create-link-display']) -- -- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the -- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current -- namespace. --]] cfg['experiment-blurb-template'] = format('experiment-blurb-template') cfg['experiment-blurb-module'] = format('experiment-blurb-module') ---------------------------------------------------------------------------------------------------- -- Sandbox link configuration ---------------------------------------------------------------------------------------------------- -- cfg['sandbox-subpage'] -- The name of the template subpage typically used for sandboxes. cfg['sandbox-subpage'] = 'sandbox' -- cfg['template-sandbox-preload'] -- Preload file for template sandbox pages. cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox' -- cfg['module-sandbox-preload'] -- Preload file for Lua module sandbox pages. cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox' -- cfg['sandbox-link-display'] -- The text to display for "sandbox" links. cfg['sandbox-link-display'] = format('sandbox-link-display') -- cfg['sandbox-edit-link-display'] -- The text to display for sandbox "edit" links. cfg['sandbox-edit-link-display'] = format('sandbox-edit-link-display') -- cfg['sandbox-create-link-display'] -- The text to display for sandbox "create" links. cfg['sandbox-create-link-display'] = format('sandbox-create-link-display') -- cfg['compare-link-display'] -- The text to display for "compare" links. cfg['compare-link-display'] = format('compare-link-display') -- cfg['mirror-edit-summary'] -- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the -- template page. cfg['mirror-edit-summary'] = 'Create sandbox version of $1' -- cfg['mirror-link-display'] -- The text to display for "mirror" links. cfg['mirror-link-display'] = format('mirror-link-display') -- cfg['mirror-link-preload'] -- The page to preload when a user clicks the "mirror" link. cfg['mirror-link-preload'] = 'Template:Documentation/mirror' ---------------------------------------------------------------------------------------------------- -- Test cases link configuration ---------------------------------------------------------------------------------------------------- -- cfg['testcases-subpage'] -- The name of the template subpage typically used for test cases. cfg['testcases-subpage'] = 'testcases' -- cfg['template-testcases-preload'] -- Preload file for template test cases pages. cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases' -- cfg['module-testcases-preload'] -- Preload file for Lua module test cases pages. cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases' -- cfg['testcases-link-display'] -- The text to display for "testcases" links. cfg['testcases-link-display'] = format('testcases-link-display') -- cfg['testcases-edit-link-display'] -- The text to display for test cases "edit" links. cfg['testcases-edit-link-display'] = format('testcases-edit-link-display') -- cfg['testcases-create-link-display'] -- The text to display for test cases "create" links. cfg['testcases-create-link-display'] = format('testcases-create-link-display') ---------------------------------------------------------------------------------------------------- -- Add categories blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['add-categories-blurb'] -- Text to direct users to add categories to the /doc subpage. Not used if the "content" or -- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a -- link to the /doc subpage with a display value of cfg['doc-link-display']. --]] cfg['add-categories-blurb'] = format('add-categories-blurb') -- cfg['doc-link-display'] -- The text to display when linking to the /doc subpage. cfg['doc-link-display'] = '/doc' ---------------------------------------------------------------------------------------------------- -- Subpages link configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['subpages-blurb'] -- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a -- display value of cfg['subpages-link-display']. In the English version this blurb is simply -- the link followed by a period, and the link display provides the actual text. --]] cfg['subpages-blurb'] = format('subpages-blurb') --[[ -- cfg['subpages-link-display'] -- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'], -- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in -- the template namespace, the module namespace, or another namespace. --]] cfg['subpages-link-display'] = format('subpages-link-display') -- cfg['template-pagetype'] -- The pagetype to display for template pages. cfg['template-pagetype'] = format('template-pagetype') -- cfg['module-pagetype'] -- The pagetype to display for Lua module pages. cfg['module-pagetype'] = format('module-pagetype') -- cfg['default-pagetype'] -- The pagetype to display for pages other than templates or Lua modules. cfg['default-pagetype'] = format('default-pagetype') ---------------------------------------------------------------------------------------------------- -- Doc link configuration ---------------------------------------------------------------------------------------------------- -- cfg['doc-subpage'] -- The name of the subpage typically used for documentation pages. cfg['doc-subpage'] = 'doc' -- cfg['file-docpage-preload'] -- Preload file for documentation page in the file namespace. cfg['file-docpage-preload'] = 'Template:Documentation/preload-filespace' -- cfg['docpage-preload'] -- Preload file for template documentation pages in all namespaces. cfg['docpage-preload'] = 'Template:Documentation/preload' -- cfg['module-preload'] -- Preload file for Lua module documentation pages. cfg['module-preload'] = 'Template:Documentation/preload-module-doc' ---------------------------------------------------------------------------------------------------- -- Print version configuration ---------------------------------------------------------------------------------------------------- -- cfg['print-subpage'] -- The name of the template subpage used for print versions. cfg['print-subpage'] = 'Print' -- cfg['print-link-display'] -- The text to display when linking to the /Print subpage. cfg['print-link-display'] = '/Print' -- cfg['print-blurb'] -- Text to display if a /Print subpage exists. $1 is a link to the subpage with a display value of cfg['print-link-display']. cfg['print-blurb'] = format('print-blurb') -- cfg['display-print-category'] -- Set to true to enable output of cfg['print-category'] if a /Print subpage exists. -- This should be a boolean value (either true or false). cfg['display-print-category'] = true -- cfg['print-category'] -- Category to output if cfg['display-print-category'] is set to true, and a /Print subpage exists. cfg['print-category'] = 'Templates with print versions' ---------------------------------------------------------------------------------------------------- -- HTML and CSS configuration ---------------------------------------------------------------------------------------------------- -- cfg['main-div-id'] -- The "id" attribute of the main HTML "div" tag. cfg['main-div-id'] = 'template-documentation' -- cfg['main-div-classes'] -- The CSS classes added to the main HTML "div" tag. cfg['main-div-class'] = 'ts-doc-doc' cfg['header-div-class'] = 'ts-doc-header' cfg['heading-div-class'] = 'ts-doc-heading' cfg['content-div-class'] = 'ts-doc-content' cfg['footer-div-class'] = 'ts-doc-footer plainlinks' cfg['sandbox-class'] = 'ts-doc-sandbox' -- cfg['start-box-linkclasses'] -- The CSS classes used for the [view][edit][history] or [create] links in the start box. cfg['start-box-linkclasses'] = 'ts-tlinks-tlinks mw-editsection-like plainlinks' -- cfg['start-box-link-id'] -- The HTML "id" attribute for the links in the start box. cfg['start-box-link-id'] = 'doc_editlinks' ---------------------------------------------------------------------------------------------------- -- Tracking category configuration ---------------------------------------------------------------------------------------------------- -- cfg['display-strange-usage-category'] -- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage -- or a /testcases subpage. This should be a boolean value (either true or false). cfg['display-strange-usage-category'] = false -- cfg['strange-usage-category'] -- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a -- /doc subpage or a /testcases subpage. cfg['strange-usage-category'] = 'Pages with strange ((documentation)) usage' --[[ ---------------------------------------------------------------------------------------------------- -- End configuration -- -- Don't edit anything below this line. ---------------------------------------------------------------------------------------------------- --]] return cfg 2d847b9bb120cb550277fa38ab17484a7cd7ed58 Module:Documentation/styles.css 828 29 97 51 2024-04-03T17:31:01Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Documentation/styles.css]] sanitized-css text/css /* {{pp|small=yes}} */ .documentation, .documentation-metadata { border: 1px solid #a2a9b1; background-color: #ecfcf4; clear: both; } .documentation { margin: 1em 0 0 0; padding: 1em; } .documentation-metadata { margin: 0.2em 0; /* same margin left-right as .documentation */ font-style: italic; padding: 0.4em 1em; /* same padding left-right as .documentation */ } .documentation-startbox { padding-bottom: 3px; border-bottom: 1px solid #aaa; margin-bottom: 1ex; } .documentation-heading { font-weight: bold; font-size: 125%; } .documentation-clear { /* Don't want things to stick out where they shouldn't. */ clear: both; } .documentation-toolbar { font-style: normal; font-size: 85%; } html.skin-theme-clientpref-night .documentation, html.skin-theme-clientpref-night .documentation-metadata { background-color: inherit; } @media (prefers-color-scheme: dark) { html.skin-theme-clientpref-os .documentation, html.skin-theme-clientpref-os .documentation-metadata { background-color: inherit; } } a086e12b14e61c1254b77cddf71625c15359e806 Template:Sandbox other 10 44 99 98 2024-04-03T17:31:02Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Sandbox_other]] wikitext text/x-wiki {{#if:{{#ifeq:{{#invoke:String|sublength|s={{SUBPAGENAME}}|i=0|len=7}}|sandbox|1}}{{#ifeq:{{SUBPAGENAME}}|doc|1}}{{#invoke:String|match|{{PAGENAME}}|/sandbox/styles.css$|plain=false|nomatch=}}|{{{1|}}}|{{{2|}}}}}<!-- --><noinclude>{{documentation}}</noinclude> 91e4ae891d6b791615152c1fbc971414961ba872 Template:Documentation subpage 10 45 101 100 2024-04-03T17:31:02Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Documentation_subpage]] wikitext text/x-wiki <includeonly><!-- -->{{#ifeq:{{lc:{{SUBPAGENAME}}}} |{{{override|doc}}} | <!--(this template has been transcluded on a /doc or /{{{override}}} page)--> </includeonly><!-- -->{{#ifeq:{{{doc-notice|show}}} |show | {{Mbox | type = notice | style = margin-bottom:1.0em; | image = [[File:Edit-copy green.svg|40px|alt=|link=]] | text = {{strong|This is a [[Wikipedia:Template documentation|documentation]] [[Wikipedia:Subpages|subpage]]}} for {{terminate sentence|{{{1|[[:{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}}}}<br />It may contain usage information, [[Wikipedia:Categorization|categories]] and other content that is not part of the original {{#if:{{{text2|}}} |{{{text2}}} |{{#if:{{{text1|}}} |{{{text1}}} |{{#ifeq:{{SUBJECTSPACE}} |{{ns:User}} |{{lc:{{SUBJECTSPACE}}}} template page |{{#if:{{SUBJECTSPACE}} |{{lc:{{SUBJECTSPACE}}}} page|article}}}}}}}}. }} }}<!-- -->{{DEFAULTSORT:{{{defaultsort|{{PAGENAME}}}}}}}<!-- -->{{#if:{{{inhibit|}}} |<!--(don't categorize)--> | <includeonly><!-- -->{{#ifexist:{{NAMESPACE}}:{{BASEPAGENAME}} | [[Category:{{#switch:{{SUBJECTSPACE}} |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]] | [[Category:Documentation subpages without corresponding pages]] }}<!-- --></includeonly> }}<!-- (completing initial #ifeq: at start of template:) --><includeonly> | <!--(this template has not been transcluded on a /doc or /{{{override}}} page)--> }}<!-- --></includeonly><noinclude>{{Documentation}}</noinclude> 41ca90af0945442788a2dbd08c8c54a61a23c057 Template:TemplateData header 10 46 103 102 2024-04-03T17:31:03Z Nulcow 2 1 revision imported from [[:wikipedia:Template:TemplateData_header]] wikitext text/x-wiki <div class="templatedata-header">{{#if:{{{noheader|}}}|<!-- noheader: -->{{Template parameter usage|{{{1|{{BASEPAGENAME}}}}}|based=y}}|<!-- +header: -->This is the {{#if:{{{nolink|}}}|<!-- +header, nolink TD -->TemplateData|<!-- +header, +link [[TD]]; DEFAULT: -->[[Wikipedia:TemplateData|TemplateData]]}}<!-- e.o. #if:nolink; DEFAULT: --> for this template used by [[mw:Extension:TemplateWizard|TemplateWizard]], [[Wikipedia:VisualEditor|VisualEditor]] and other tools. {{Template parameter usage|{{{1|{{BASEPAGENAME}}}}}|based=y}}<!-- e.o. #if:noheader -->}} '''TemplateData for {{{1|{{BASEPAGENAME}}}}}''' </div><includeonly><!-- check parameters -->{{#invoke:Check for unknown parameters|check |unknown={{template other|1=[[Category:Pages using TemplateData header with unknown parameters|_VALUE_]]}} |template=Template:TemplateData header |1 |nolink |noheader |preview=<div class="error" style="font-weight:normal">Unknown parameter '_VALUE_' in [[Template:TemplateData header]].</div> }}<!-- -->{{template other|{{sandbox other|| [[Category:Templates using TemplateData]] }}}}</includeonly><!-- --><noinclude>{{Documentation}}</noinclude> 748b89c815a11e78b365c5617460ea569f3f96cb Template:Template parameter usage 10 47 105 104 2024-04-03T17:31:03Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Template_parameter_usage]] wikitext text/x-wiki {{#switch:{{{label|}}} |=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|S|s}}ee a monthly parameter usage report] for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|this template}} in articles{{#ifeq:{{yesno-no|{{{based}}}}}|yes|&#32;based on {{#if:{{{1|}}}|its|this}} TemplateData}}. |None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|P|p}}arameter usage report]{{#ifeq:{{yesno-no|{{{based}}}}}|yes|&#32;based on {{#if:{{{1|}}}|its|this}} TemplateData}} |for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{#ifeq:{{yesno-no|{{{lc}}}}}|no|P|p}}arameter usage report] for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|[[Template:{{ROOTPAGENAME}}]]}}{{#ifeq:{{yesno-no|{{{based}}}}}|yes|&#32;based on {{#if:{{{1|}}}|its|this}} TemplateData}}. |#default=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{{label|}}}]{{#ifeq:{{yesno-no|{{{based}}}}}|yes|&#32;based on {{#if:{{{1|}}}|its|this}} TemplateData}} }}<noinclude> {{documentation}} </noinclude> 83e574f5e031df639a2cdcef5b91d6b1094ae648 Module:High-use 828 48 107 106 2024-04-03T17:31:03Z Nulcow 2 1 revision imported from [[:wikipedia:Module:High-use]] Scribunto text/plain local p = {} -- _fetch looks at the "demo" argument. local _fetch = require('Module:Transclusion_count').fetch local yesno = require('Module:Yesno') function p.num(frame, count) if count == nil then if yesno(frame.args['fetch']) == false then if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end else count = _fetch(frame) end end -- Build output string local return_value = "" if count == nil then if frame.args[1] == "risk" then return "a very large number of" else return "many" end else -- Use 2 significant figures for smaller numbers and 3 for larger ones local sigfig = 2 if count >= 100000 then sigfig = 3 end -- Prepare to round to appropriate number of sigfigs local f = math.floor(math.log10(count)) - sigfig + 1 -- Round and insert "approximately" or "+" when appropriate if (frame.args[2] == "yes") or (mw.ustring.sub(frame.args[1],-1) == "+") then -- Round down return_value = string.format("%s+", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) ) * (10^(f))) ) else -- Round to nearest return_value = string.format("approximately&#x20;%s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) ) end -- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yes if count and count > 250000 and not yesno (frame:getParent().args['no-percent']) then local percent = math.floor( ( (count/frame:callParserFunction('NUMBEROFPAGES', 'R') ) * 100) + 0.5) if percent >= 1 then return_value = string.format("%s&#x20;pages, or roughly %s%% of all", return_value, percent) end end end return return_value end -- Actions if there is a large (greater than or equal to 100,000) transclusion count function p.risk(frame) if frame.args[1] == "risk" then return "risk" else local count = _fetch(frame) if count and count >= 100000 then return "risk" end end return "" end function p.text(frame, count) -- Only show the information about how this template gets updated if someone -- is actually editing the page and maybe trying to update the count. local bot_text = (frame:preprocess("{{REVISIONID}}") == "") and "\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]])." or '' if count == nil then if yesno(frame.args['fetch']) == false then if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end else count = _fetch(frame) end end local title = mw.title.getCurrentTitle() if title.subpageText == "doc" or title.subpageText == "sandbox" then title = title.basePageTitle end local systemMessages = frame.args['system'] if frame.args['system'] == '' then systemMessages = nil end -- This retrieves the project URL automatically to simplify localiation. local templateCount = ('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format( mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'), mw.uri.encode(title.fullText), p.num(frame, count)) local used_on_text = "'''This " .. (mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template") .. ' is used '; if systemMessages then used_on_text = used_on_text .. systemMessages .. ((count and count > 2000) and ("''', and " .. templateCount) or ("'''")) else used_on_text = used_on_text .. templateCount .. "'''" end local sandbox_text = ("%s's [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages, or in your own [[%s]]. "):format( (mw.title.getCurrentTitle().namespace == 828 and "module" or "template"), title.fullText, title.fullText, mw.title.getCurrentTitle().namespace == 828 and "Module:Sandbox|module sandbox" or "Wikipedia:User pages#SUB|user subpage" ) local infoArg = frame.args["info"] ~= "" and frame.args["info"] if (systemMessages or frame.args[1] == "risk" or (count and count >= 100000) ) then local info = systemMessages and '.<br/>Changes to it can cause immediate changes to the Wikipedia user interface.' or '.' if infoArg then info = info .. "<br />" .. infoArg end sandbox_text = info .. '<br /> To avoid major disruption' .. (count and count >= 100000 and ' and server load' or '') .. ', any changes should be tested in the ' .. sandbox_text .. 'The tested changes can be added to this page in a single edit. ' else sandbox_text = (infoArg and ('.<br />' .. infoArg .. ' C') or ' and c') .. 'hanges may be widely noticed. Test changes in the ' .. sandbox_text end local discussion_text = systemMessages and 'Please discuss changes ' or 'Consider discussing changes ' if frame.args["2"] and frame.args["2"] ~= "" and frame.args["2"] ~= "yes" then discussion_text = string.format("%sat [[%s]]", discussion_text, frame.args["2"]) else discussion_text = string.format("%son the [[%s|talk page]]", discussion_text, title.talkPageTitle.fullText ) end return used_on_text .. sandbox_text .. discussion_text .. " before implementing them." .. bot_text end function p.main(frame) local count = nil if yesno(frame.args['fetch']) == false then if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end else count = _fetch(frame) end local image = "[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]" local type_param = "style" local epilogue = '' if frame.args['system'] and frame.args['system'] ~= '' then image = "[[File:Ambox important.svg|40px|alt=Warning|link=]]" type_param = "content" local nocat = frame:getParent().args['nocat'] or frame.args['nocat'] local categorise = (nocat == '' or not yesno(nocat)) if categorise and not mw.title.getCurrentTitle().isRedirect then epilogue = frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}') end elseif (frame.args[1] == "risk" or (count and count >= 100000)) then image = "[[File:Ambox warning orange.svg|40px|alt=Warning|link=]]" type_param = "content" end if frame.args["form"] == "editnotice" then return frame:expandTemplate{ title = 'editnotice', args = { ["image"] = image, ["text"] = p.text(frame, count), ["expiry"] = (frame.args["expiry"] or "") } } .. epilogue else return require('Module:Message box').main('ombox', { type = type_param, image = image, text = p.text(frame, count), expiry = (frame.args["expiry"] or "") }) .. epilogue end end return p e22649bbbdf0185575aade09174113873db5066a Module:Transclusion count 828 49 109 108 2024-04-03T17:31:04Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Transclusion_count]] Scribunto text/plain local p = {} function p.fetch(frame) local template = nil local return_value = nil -- Use demo parameter if it exists, otherswise use current template name local namespace = mw.title.getCurrentTitle().namespace if frame.args["demo"] and frame.args["demo"] ~= "" then template = mw.ustring.gsub(frame.args["demo"],"^[Tt]emplate:","") elseif namespace == 10 then -- Template namespace template = mw.title.getCurrentTitle().text elseif namespace == 828 then -- Module namespace template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text) end -- If in template or module namespace, look up count in /data if template ~= nil then namespace = mw.title.new(template, "Template").namespace if namespace == 10 or namespace == 828 then template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end template = mw.ustring.gsub(template, "/sandbox$", "") -- strip /sandbox from end local index = mw.ustring.sub(mw.title.new(template).text,1,1) local status, data = pcall(function () return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other"))) end) if status then return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")]) end end end -- If database value doesn't exist, use value passed to template if return_value == nil and frame.args[1] ~= nil then local arg1=mw.ustring.match(frame.args[1], '[%d,]+') if arg1 and arg1 ~= '' then return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R')) end end return return_value end -- Tabulate this data for [[Wikipedia:Database reports/Templates transcluded on the most pages]] function p.tabulate(frame) local list = {} for i = 65, 91 do local data = mw.loadData('Module:Transclusion count/data/' .. ((i == 91) and 'other' or string.char(i))) for name, count in pairs(data) do table.insert(list, {mw.title.new(name, "Template").fullText, count}) end end table.sort(list, function(a, b) return (a[2] == b[2]) and (a[1] < b[1]) or (a[2] > b[2]) end) local lang = mw.getContentLanguage(); for i = 1, #list do list[i] = ('|-\n| %d || [[%s]] || %s\n'):format(i, list[i][1]:gsub('_', ' '), lang:formatNum(list[i][2])) end return table.concat(list) end return p 000ef6bcbf7b66e727870b0c300c4009da300513 Module:Transclusion count/data/S 828 50 111 110 2024-04-03T17:31:04Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Transclusion_count/data/S]] Scribunto text/plain return { ["S"] = 3700, ["S-aca"] = 6500, ["S-ach"] = 16000, ["S-aft"] = 220000, ["S-aft/check"] = 220000, ["S-aft/filter"] = 220000, ["S-bef"] = 225000, ["S-bef/check"] = 225000, ["S-bef/filter"] = 225000, ["S-break"] = 5200, ["S-civ"] = 2700, ["S-dip"] = 5500, ["S-end"] = 249000, ["S-gov"] = 8000, ["S-hon"] = 3900, ["S-hou"] = 9600, ["S-inc"] = 13000, ["S-legal"] = 9500, ["S-mil"] = 12000, ["S-new"] = 16000, ["S-non"] = 10000, ["S-npo"] = 4100, ["S-off"] = 41000, ["S-par"] = 51000, ["S-par/en"] = 3300, ["S-par/gb"] = 3300, ["S-par/uk"] = 12000, ["S-par/us-hs"] = 11000, ["S-par/us-sen"] = 2000, ["S-ppo"] = 13000, ["S-prec"] = 3200, ["S-rail"] = 6400, ["S-rail-start"] = 6300, ["S-rail/lines"] = 6400, ["S-reg"] = 21000, ["S-rel"] = 18000, ["S-roy"] = 2800, ["S-s"] = 2800, ["S-sports"] = 11000, ["S-start"] = 242000, ["S-ttl"] = 232000, ["S-ttl/check"] = 232000, ["S-vac"] = 6600, ["SCO"] = 3700, ["SDcat"] = 5730000, ["SECOND"] = 2300, ["SGP"] = 2700, ["SIA"] = 2600, ["SIPA"] = 2800, ["SLO"] = 4300, ["SMS"] = 7400, ["SMU"] = 2200, ["SPI_archive_notice"] = 73000, ["SPIarchive_notice"] = 73000, ["SPIcat"] = 3800, ["SPIclose"] = 3300, ["SPIpriorcases"] = 67000, ["SR/Olympics_profile"] = 3000, ["SRB"] = 3700, ["SS"] = 20000, ["SSPa"] = 2600, ["STN"] = 13000, ["SUBJECTSPACE_formatted"] = 44000, ["SUI"] = 8600, ["SVG"] = 3100, ["SVG-Logo"] = 21000, ["SVG-Res"] = 19000, ["SVG-logo"] = 7900, ["SVK"] = 6000, ["SVN"] = 5200, ["SWE"] = 12000, ["Sandbox_other"] = 247000, ["Saturday"] = 2700, ["Saved_book"] = 52000, ["Sc"] = 2800, ["Scholia"] = 3000, ["School_block"] = 13000, ["School_disambiguation"] = 3300, ["Schoolblock"] = 6800, ["Schooldis"] = 2600, ["Schoolip"] = 11000, ["Scientist_icon"] = 15000, ["Scientist_icon2"] = 15000, ["Sclass"] = 31000, ["Sclass2"] = 10000, ["Screen_reader-only"] = 44000, ["Screen_reader-only/styles.css"] = 45000, ["Script"] = 6200, ["Script/Arabic"] = 2900, ["Script/Hebrew"] = 4800, ["Script/Nastaliq"] = 14000, ["Script/doc/id-unk"] = 3000, ["Script/doc/id-unk/core"] = 3000, ["Script/doc/id-unk/is-iso-alpha4"] = 2900, ["Script/doc/id-unk/name-to-alpha4"] = 3000, ["Script/styles.css"] = 3100, ["Script/styles_arabic.css"] = 2900, ["Script/styles_hebrew.css"] = 4800, ["Sdash"] = 3300, ["Search_box"] = 55000, ["Search_link"] = 16000, ["Section_link"] = 70000, ["Section_sizes"] = 2700, ["See"] = 9900, ["See_also"] = 190000, ["Seealso"] = 6800, ["Select_skin"] = 4400, ["Selected_article"] = 2500, ["Selected_picture"] = 2500, ["Self"] = 46000, ["Self-published_inline"] = 4100, ["Self-published_source"] = 6500, ["Self-reference"] = 2400, ["Self-reference_tool"] = 5700, ["Sent_off"] = 14000, ["Sentoff"] = 4500, ["Separated_entries"] = 196000, ["Sequence"] = 3500, ["Series_overview"] = 8200, ["Serif"] = 3000, ["Set_category"] = 36000, ["Set_index_article"] = 6000, ["Sets_taxobox_colour"] = 68000, ["Sfn"] = 163000, ["SfnRef"] = 138000, ["Sfnm"] = 4000, ["Sfnp"] = 18000, ["Sfnref"] = 12000, ["Sfrac"] = 4400, ["Sfrac/styles.css"] = 4400, ["SharedIPEDU"] = 3300, ["Shared_IP"] = 10000, ["Shared_IP_advice"] = 15000, ["Shared_IP_corp"] = 4300, ["Shared_IP_edu"] = 183000, ["Shared_IP_gov"] = 2400, ["Sharedip"] = 3000, ["Sharedipedu"] = 3700, ["Sherdog"] = 2600, ["Ship"] = 86000, ["Ship/maintenancecategory"] = 86000, ["Ship_index"] = 7000, ["Shipboxflag"] = 20000, ["Shipboxflag/core"] = 20000, ["Shipwrecks_navbox_footer"] = 10000, ["Shipwrecks_navbox_footer/link"] = 10000, ["Short_description"] = 5840000, ["Short_description/lowercasecheck"] = 5840000, ["Short_pages_monitor"] = 11000, ["Short_pages_monitor/maximum_length"] = 11000, ["Shortcut"] = 20000, ["Should_be_SVG"] = 8800, ["Shy"] = 2900, ["Sic"] = 33000, ["Sica"] = 3100, ["Side_box"] = 1190000, ["Sidebar"] = 264000, ["Sidebar_games_events"] = 38000, ["Sidebar_person"] = 2500, ["Sidebar_person/styles.css"] = 2500, ["Sidebar_with_collapsible_lists"] = 95000, ["Sigfig"] = 3900, ["Significant_figures"] = 5300, ["Significant_figures/rnd"] = 4900, ["Signpost-subscription"] = 2100, ["Signpost/item"] = 40000, ["Sildb_prim"] = 2100, ["Silver02"] = 17000, ["Silver2"] = 50000, ["Silver_medal"] = 5800, ["Similar_names"] = 2300, ["Single+double"] = 7700, ["Single+space"] = 15000, ["Single-innings_cricket_match"] = 3400, ["Single_chart"] = 38000, ["Single_chart/chartnote"] = 38000, ["Single_namespace"] = 205000, ["Singlechart"] = 19000, ["Singles"] = 43000, ["Sister-inline"] = 194000, ["Sister_project"] = 1060000, ["Sister_project_links"] = 11000, ["Sisterlinks"] = 2200, ["Skip_to_talk"] = 12000, ["Skip_to_talk/styles.css"] = 12000, ["Sky"] = 2700, ["Sky/styles.css"] = 2700, ["Slink"] = 19000, ["Small"] = 615000, ["Small_Solar_System_bodies"] = 3600, ["Smallcaps"] = 17000, ["Smallcaps/styles.css"] = 18000, ["Smallcaps_all"] = 2900, ["Smalldiv"] = 23000, ["Smaller"] = 77000, ["Smallsup"] = 21000, ["Smiley"] = 45000, ["Snd"] = 188000, ["Snds"] = 6400, ["Soccer_icon"] = 129000, ["Soccer_icon2"] = 129000, ["Soccer_icon4"] = 5100, ["Soccerbase"] = 13000, ["Soccerbase_season"] = 7000, ["Soccerway"] = 78000, ["Sock"] = 49000, ["Sock_list"] = 5500, ["Sockcat"] = 2000, ["Sockmaster"] = 9600, ["Sockpuppet"] = 249000, ["Sockpuppet/altmaster"] = 2700, ["Sockpuppet/categorise"] = 249000, ["SockpuppetCheckuser"] = 5500, ["Sockpuppet_category"] = 47000, ["Sockpuppet_category/confirmed"] = 24000, ["Sockpuppet_category/suspected"] = 22000, ["Sockpuppetcheckuser"] = 3600, ["Sockpuppeteer"] = 25000, ["Soft_hyphen"] = 3000, ["Soft_redirect"] = 6000, ["Soft_redirect_protection"] = 8100, ["Softredirect"] = 3300, ["Solar_luminosity"] = 4500, ["Solar_mass"] = 5400, ["Solar_radius"] = 4400, ["Soldier_icon"] = 3900, ["Soldier_icon2"] = 3900, ["Songs"] = 2100, ["Songs_category"] = 8700, ["Songs_category/core"] = 8700, ["Sort"] = 102000, ["Sortname"] = 54000, ["Source-attribution"] = 30000, ["Source_check"] = 960000, ["Sourcecheck"] = 960000, ["Sources"] = 3200, ["Sources_exist"] = 2200, ["South_America_topic"] = 2500, ["Sp"] = 171000, ["Space"] = 56000, ["Space+double"] = 19000, ["Space+single"] = 13000, ["Spaced_en_dash"] = 220000, ["Spaced_en_dash_space"] = 6400, ["Spaced_ndash"] = 22000, ["Spaces"] = 582000, ["Spain_metadata_Wikidata"] = 7500, ["Spamlink"] = 13000, ["Species_Latin_name_abbreviation_disambiguation"] = 2200, ["Species_list"] = 16000, ["Speciesbox"] = 314000, ["Speciesbox/getGenus"] = 314000, ["Speciesbox/getSpecies"] = 314000, ["Speciesbox/name"] = 314000, ["Speciesbox/parameterCheck"] = 314000, ["Speciesbox/trim"] = 314000, ["Specieslist"] = 6300, ["Split_article"] = 3800, ["Spnd"] = 4300, ["Sport_icon"] = 14000, ["Sport_icon2"] = 15000, ["SportsYearCatUSstate"] = 6500, ["SportsYearCatUSstate/core"] = 6500, ["Sports_links"] = 69000, ["Sports_reference"] = 6700, ["Squad_maintenance"] = 3600, ["Sronly"] = 42000, ["Srt"] = 5700, ["Stack"] = 26000, ["Stack/styles.css"] = 35000, ["Stack_begin"] = 9500, ["Stack_end"] = 9500, ["StaleIP"] = 3300, ["Standings_table_end"] = 56000, ["Standings_table_entry"] = 56000, ["Standings_table_entry/record"] = 56000, ["Standings_table_start"] = 56000, ["Standings_table_start/colheader"] = 56000, ["Standings_table_start/colspan"] = 56000, ["Standings_table_start/styles.css"] = 56000, ["Starbox_astrometry"] = 5200, ["Starbox_begin"] = 5400, ["Starbox_catalog"] = 5300, ["Starbox_character"] = 5200, ["Starbox_detail"] = 5100, ["Starbox_end"] = 5300, ["Starbox_image"] = 3000, ["Starbox_observe"] = 5200, ["Starbox_reference"] = 5300, ["Start-Class"] = 18000, ["Start-date"] = 3700, ["Start_and_end_dates"] = 2800, ["Start_box"] = 7500, ["Start_date"] = 449000, ["Start_date_and_age"] = 150000, ["Start_date_and_years_ago"] = 6000, ["Start_date_text"] = 3800, ["Start_of_course_timeline"] = 5900, ["Start_of_course_week"] = 6000, ["Start_tab"] = 5300, ["Startflatlist"] = 147000, ["Static_IP"] = 5500, ["Station"] = 8000, ["Station_link"] = 16000, ["Stdinchicite"] = 11000, ["Steady"] = 15000, ["Stl"] = 14000, ["Stn"] = 7600, ["Stn_art_lnk"] = 2100, ["Stnlnk"] = 31000, ["Storm_colour"] = 5200, ["Storm_name"] = 2100, ["Storm_path"] = 2100, ["StoryTeleplay"] = 3600, ["Str_count"] = 5800, ["Str_endswith"] = 209000, ["Str_find"] = 279000, ["Str_index"] = 13000, ["Str_left"] = 930000, ["Str_len"] = 21000, ["Str_letter"] = 177000, ["Str_letter/trim"] = 20000, ["Str_number"] = 8000, ["Str_number/trim"] = 187000, ["Str_rep"] = 269000, ["Str_trim"] = 5000, ["Str_≠_len"] = 37000, ["Str_≥_len"] = 79000, ["Strfind_short"] = 236000, ["Strikethrough"] = 17000, ["String_split"] = 6300, ["Strip_tags"] = 38000, ["Strong"] = 902000, ["Structurae"] = 2100, ["Stub-Class"] = 18000, ["Stub_Category"] = 13000, ["Stub_category"] = 18000, ["Stub_documentation"] = 37000, ["Student_editor"] = 27000, ["Student_sandbox"] = 4500, ["Student_table_row"] = 5700, ["Students_table"] = 5700, ["Su"] = 10000, ["Su-census1989"] = 4400, ["Sub"] = 5200, ["Subinfobox_bodystyle"] = 36000, ["Subject_bar"] = 17000, ["Suboff"] = 6500, ["Subon"] = 6600, ["Subpage_other"] = 307000, ["Subscription"] = 4200, ["Subscription_required"] = 33000, ["Subsidebar_bodystyle"] = 6200, ["Subst_only"] = 5300, ["Substituted_comment"] = 19000, ["Succession_box"] = 118000, ["Succession_box/check"] = 118000, ["Succession_links"] = 183000, ["Summer_Olympics_by_year_category_navigation"] = 2400, ["Summer_Olympics_by_year_category_navigation/core"] = 2400, ["Sunday"] = 2700, ["Sup"] = 60000, ["Suppress_categories"] = 5500, ["Surname"] = 69000, ["Swiss_populations"] = 2400, ["Swiss_populations_NC"] = 3000, ["Swiss_populations_YM"] = 2300, ["Swiss_populations_ref"] = 2400, ["Switcher"] = 4000, ["Module:SDcat"] = 5730000, ["Module:SPI_archive_notice"] = 34000, ["Module:Science_redirect"] = 268000, ["Module:Science_redirect/conf"] = 268000, ["Module:Section_link"] = 70000, ["Module:Section_sizes"] = 4200, ["Module:See_also_if_exists"] = 76000, ["Module:Self"] = 46000, ["Module:Self/license_migration_data.json"] = 22000, ["Module:Self/styles.css"] = 46000, ["Module:Separated_entries"] = 2360000, ["Module:Series_overview"] = 8200, ["Module:Settlement_short_description"] = 713000, ["Module:Shortcut"] = 24000, ["Module:Shortcut/config"] = 24000, ["Module:Shortcut/styles.css"] = 24000, ["Module:Side_box"] = 1220000, ["Module:Side_box/styles.css"] = 1220000, ["Module:Sidebar"] = 346000, ["Module:Sidebar/configuration"] = 346000, ["Module:Sidebar/styles.css"] = 352000, ["Module:Sidebar_games_events"] = 38000, ["Module:Sidebar_games_events/styles.css"] = 38000, ["Module:Singles"] = 43000, ["Module:Sister_project_links"] = 15000, ["Module:Sister_project_links/bar/styles.css"] = 3800, ["Module:Sister_project_links/styles.css"] = 11000, ["Module:Sock_list"] = 5500, ["Module:Sort_title"] = 20000, ["Module:Sortkey"] = 203000, ["Module:Split_article"] = 3800, ["Module:Sports_career"] = 19000, ["Module:Sports_color"] = 69000, ["Module:Sports_color/baseball"] = 34000, ["Module:Sports_color/basketball"] = 23000, ["Module:Sports_color/ice_hockey"] = 3200, ["Module:Sports_rbr_table"] = 12000, ["Module:Sports_rbr_table/styles.css"] = 12000, ["Module:Sports_reference"] = 6700, ["Module:Sports_results"] = 15000, ["Module:Sports_results/styles.css"] = 9800, ["Module:Sports_table"] = 60000, ["Module:Sports_table/Volleyball"] = 2000, ["Module:Sports_table/WDL"] = 53000, ["Module:Sports_table/WDL_OT"] = 2900, ["Module:Sports_table/WL"] = 4300, ["Module:Sports_table/WL_OT"] = 2200, ["Module:Sports_table/argcheck"] = 60000, ["Module:Sports_table/styles.css"] = 60000, ["Module:Sports_table/sub"] = 61000, ["Module:Sports_table/totalscheck"] = 44000, ["Module:Stock_tickers/NYSE"] = 2000, ["Module:Storm_categories"] = 5300, ["Module:Storm_categories/categories"] = 5300, ["Module:Storm_categories/colors"] = 5300, ["Module:Storm_categories/icons"] = 5300, ["Module:String"] = 9910000, ["Module:String2"] = 4710000, ["Module:Su"] = 12000, ["Module:Subject_bar"] = 17000, ["Module:Suppress_categories"] = 5500, } 5c6fed328e89ac4fd7b6fa54fde5bc857b599a5a Template:Stub/doc 10 51 113 112 2024-04-03T17:31:05Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Stub/doc]] wikitext text/x-wiki {{documentation subpage}} <!-- Intentionally blank: interlanguage links for [[Template:Stub]] are now held at [[d:Special:ItemByTitle/enwiki/Template:Stub]]. --> ===TemplateData=== {{TemplateData header}} <templatedata> { "description": "Standard template used for sorting articles into stubs.", "params": {}, "format": "inline" } </templatedata> 4e08e86ecdef137b8a8a26bf6766217f8fc8e0ce Template:Stub documentation 10 52 115 114 2024-04-03T17:31:05Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Stub_documentation]] wikitext text/x-wiki {{#ifeq:{{FULLPAGENAME}}|Template:Stub documentation||{{#ifeq:{{#invoke:High-use|num|x}}|many||{{High-use}}}}}} This is a '''stub template'''. A brief explanation of these templates follows; for full details please consult [[Wikipedia:Stub]]. === What is a stub? === A stub is an article containing only a few sentences of text which is too short to provide encyclopedic coverage of a subject. === How is a stub identified? === * If possible, try to find the most appropriate stub template for the article. A full list can be found at [[Wikipedia:WikiProject Stub sorting/List of stubs]]. * More than one stub template may be used, if necessary, though no more than four should be used on any article. * Place a stub template ''[[Wikipedia:Manual of Style/Layout#Order of article elements|at the very end]]'' of the article, after the "External links" section, any navigation templates, and the category tags. As usual, templates are added by including their name inside double braces, e.g. <code><nowiki>{{stub}}</nowiki></code>. === Further information === Further information can be found at: * [[Wikipedia:Stub]] * [[Wikipedia:WikiProject Stub sorting]] New stub templates and categories (collectively "stub types") should not be created without prior proposal at [[Wikipedia:WikiProject Stub sorting/Proposals]]. This allows for the proper coordination of all stub types across Wikipedia, and for the checking of any new stub type for possible problems prior to its creation. === See also === * [[Template:Empty section]] – To flag an empty section as a '''stub section''' * [[Template:Expand section]] – To flag sections selectively as incomplete * [[Template:Data missing]] – To flag missing information or other data * [[Wikipedia:Content assessment]]<!-- --><noinclude> {{documentation}} </noinclude> 693be74f03bfbb6824dc219028fd113c04317947 Template:Hlist/styles.css 10 53 117 116 2024-04-03T17:31:05Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Hlist/styles.css]] sanitized-css text/css /* {{pp-protected|reason=match parent|small=yes}} */ /* * hlist styles are defined in core and Minerva and differ in Minerva. The * current definitions here (2023-01-01) are sufficient to override Minerva * without use of the hlist-separated class. The most problematic styles were * related to margin, padding, and the bullet. Check files listed at * [[MediaWiki talk:Common.css/to do#hlist-separated]] */ /* * TODO: When the majority of readership supports it (or some beautiful world * in which grade C support is above the minimum threshold), use :is() */ .hlist dl, .hlist ol, .hlist ul { margin: 0; padding: 0; } /* Display list items inline */ .hlist dd, .hlist dt, .hlist li { /* * don't trust the note that says margin doesn't work with inline * removing margin: 0 makes dds have margins again * We also want to reset margin-right in Minerva */ margin: 0; display: inline; } /* Display requested top-level lists inline */ .hlist.inline, .hlist.inline dl, .hlist.inline ol, .hlist.inline ul, /* Display nested lists inline */ .hlist dl dl, .hlist dl ol, .hlist dl ul, .hlist ol dl, .hlist ol ol, .hlist ol ul, .hlist ul dl, .hlist ul ol, .hlist ul ul { display: inline; } /* Hide empty list items */ .hlist .mw-empty-li { display: none; } /* TODO: :not() can maybe be used here to remove the later rule. naive test * seems to work. more testing needed. like so: *.hlist dt:not(:last-child)::after { * content: ": "; *} *.hlist dd:not(:last-child)::after, *.hlist li:not(:last-child)::after { * content: " · "; * font-weight: bold; *} */ /* Generate interpuncts */ .hlist dt::after { content: ": "; } .hlist dd::after, .hlist li::after { content: " · "; font-weight: bold; } .hlist dd:last-child::after, .hlist dt:last-child::after, .hlist li:last-child::after { content: none; } /* Add parentheses around nested lists */ .hlist dd dd:first-child::before, .hlist dd dt:first-child::before, .hlist dd li:first-child::before, .hlist dt dd:first-child::before, .hlist dt dt:first-child::before, .hlist dt li:first-child::before, .hlist li dd:first-child::before, .hlist li dt:first-child::before, .hlist li li:first-child::before { content: " ("; font-weight: normal; } .hlist dd dd:last-child::after, .hlist dd dt:last-child::after, .hlist dd li:last-child::after, .hlist dt dd:last-child::after, .hlist dt dt:last-child::after, .hlist dt li:last-child::after, .hlist li dd:last-child::after, .hlist li dt:last-child::after, .hlist li li:last-child::after { content: ")"; font-weight: normal; } /* Put ordinals in front of ordered list items */ .hlist ol { counter-reset: listitem; } .hlist ol > li { counter-increment: listitem; } .hlist ol > li::before { content: " " counter(listitem) "\a0"; } .hlist dd ol > li:first-child::before, .hlist dt ol > li:first-child::before, .hlist li ol > li:first-child::before { content: " (" counter(listitem) "\a0"; } 8c9dd9c9c00f30eead17fe10f51d183333e81f33 Template:Message box 10 54 119 118 2024-04-03T17:32:18Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Message_box]] wikitext text/x-wiki {{Mbox | image = {{#if:{{{image|}}}|[[Image:{{{image}}}|45px]]|none}} | style = {{#if:{{{backgroundcolor|}}}|background: {{{backgroundcolor}}}}} | text = {{#if:{{{heading|}}}|'''{{{heading|}}}'''<br />}}{{{message|{{{text|<noinclude>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</noinclude>}}}}}} | small = {{{small|}}} | smallimage = {{#if:{{{image|}}}|[[Image:{{{image}}}|30px]]|none}} }}<noinclude>{{Documentation}}<!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS --></noinclude> 3da822df71362ab9db8cae8bd8fc8b1318ba1d25 Template:Mbox 10 55 121 120 2024-04-03T17:32:19Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Mbox]] wikitext text/x-wiki {{#invoke:Message box|mbox}}<noinclude> {{documentation}} <!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! --> </noinclude> 5bfb2becf8bed35974b47e3ff8660dc14bee40c7 Template:Tl 10 56 123 122 2024-04-03T17:32:20Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Tl]] wikitext text/x-wiki #REDIRECT [[Template:Template link]] {{Redirect category shell| {{R from move}} }} d6593bb3b4a866249f55d0f34b047a71fe1f1529 Template:Template link 10 57 125 124 2024-04-03T17:32:20Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Template_link]] wikitext text/x-wiki &#123;&#123;[[Template:{{{1}}}|{{{1}}}]]&#125;&#125;<noinclude>{{documentation}} <!-- Categories go on the /doc subpage and interwikis go on Wikidata. --> </noinclude> eabbec62efe3044a98ebb3ce9e7d4d43c222351d Module:Message box 828 10 127 23 2024-04-03T17:32:21Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Message_box]] Scribunto text/plain -- This is a meta-module for producing message box templates, including -- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}. -- Load necessary modules. require('strict') local getArgs local yesno = require('Module:Yesno') -- Get a language object for formatDate and ucfirst. local lang = mw.language.getContentLanguage() -- Define constants local CONFIG_MODULE = 'Module:Message box/configuration' local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} local TEMPLATE_STYLES = 'Module:Message box/%s.css' -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function getTitleObject(...) -- Get the title object, passing the function through pcall -- in case we are over the expensive function count limit. local success, title = pcall(mw.title.new, ...) if success then return title end end local function union(t1, t2) -- Returns the union of two arrays. local vals = {} for i, v in ipairs(t1) do vals[v] = true end for i, v in ipairs(t2) do vals[v] = true end local ret = {} for k in pairs(vals) do table.insert(ret, k) end table.sort(ret) return ret end local function getArgNums(args, prefix) local nums = {} for k, v in pairs(args) do local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end -------------------------------------------------------------------------------- -- Box class definition -------------------------------------------------------------------------------- local MessageBox = {} MessageBox.__index = MessageBox function MessageBox.new(boxType, args, cfg) args = args or {} local obj = {} obj.boxType = boxType -- Set the title object and the namespace. obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle() -- Set the config for our box type. obj.cfg = cfg[boxType] if not obj.cfg then local ns = obj.title.namespace -- boxType is "mbox" or invalid input if args.demospace and args.demospace ~= '' then -- implement demospace parameter of mbox local demospace = string.lower(args.demospace) if DEMOSPACES[demospace] then -- use template from DEMOSPACES obj.cfg = cfg[DEMOSPACES[demospace]] obj.boxType = DEMOSPACES[demospace] elseif string.find( demospace, 'talk' ) then -- demo as a talk page obj.cfg = cfg.tmbox obj.boxType = 'tmbox' else -- default to ombox obj.cfg = cfg.ombox obj.boxType = 'ombox' end elseif ns == 0 then obj.cfg = cfg.ambox -- main namespace obj.boxType = 'ambox' elseif ns == 6 then obj.cfg = cfg.imbox -- file namespace obj.boxType = 'imbox' elseif ns == 14 then obj.cfg = cfg.cmbox -- category namespace obj.boxType = 'cmbox' else local nsTable = mw.site.namespaces[ns] if nsTable and nsTable.isTalk then obj.cfg = cfg.tmbox -- any talk namespace obj.boxType = 'tmbox' else obj.cfg = cfg.ombox -- other namespaces or invalid input obj.boxType = 'ombox' end end end -- Set the arguments, and remove all blank arguments except for the ones -- listed in cfg.allowBlankParams. do local newArgs = {} for k, v in pairs(args) do if v ~= '' then newArgs[k] = v end end for i, param in ipairs(obj.cfg.allowBlankParams or {}) do newArgs[param] = args[param] end obj.args = newArgs end -- Define internal data structure. obj.categories = {} obj.classes = {} -- For lazy loading of [[Module:Category handler]]. obj.hasCategories = false return setmetatable(obj, MessageBox) end function MessageBox:addCat(ns, cat, sort) if not cat then return nil end if sort then cat = string.format('[[Category:%s|%s]]', cat, sort) else cat = string.format('[[Category:%s]]', cat) end self.hasCategories = true self.categories[ns] = self.categories[ns] or {} table.insert(self.categories[ns], cat) end function MessageBox:addClass(class) if not class then return nil end self.classes[class] = 1 end function MessageBox:removeClass(class) if not class then return nil end self.classes[class] = nil end function MessageBox:setParameters() local args = self.args local cfg = self.cfg -- Get type data. self.type = args.type local typeData = cfg.types[self.type] self.invalidTypeError = cfg.showInvalidTypeError and self.type and not typeData typeData = typeData or cfg.types[cfg.default] self.typeClass = typeData.class self.typeImage = typeData.image -- Find if the box has been wrongly substituted. self.isSubstituted = cfg.substCheck and args.subst == 'SUBST' -- Find whether we are using a small message box. self.isSmall = cfg.allowSmall and ( cfg.smallParam and args.small == cfg.smallParam or not cfg.smallParam and yesno(args.small) ) -- Add attributes, classes and styles. self.id = args.id self.name = args.name for _, class in ipairs(cfg.classes or {}) do self:addClass(class) end if self.name then self:addClass('box-' .. string.gsub(self.name,' ','_')) end local plainlinks = yesno(args.plainlinks) if plainlinks == true then self:addClass('plainlinks') elseif plainlinks == false then self:removeClass('plainlinks') end if self.isSmall then self:addClass(cfg.smallClass or 'mbox-small') end self:addClass(self.typeClass) self:addClass(args.class) self.style = args.style self.attrs = args.attrs -- Set text style. self.textstyle = args.textstyle -- Find if we are on the template page or not. This functionality is only -- used if useCollapsibleTextFields is set, or if both cfg.templateCategory -- and cfg.templateCategoryRequireName are set. self.useCollapsibleTextFields = cfg.useCollapsibleTextFields if self.useCollapsibleTextFields or cfg.templateCategory and cfg.templateCategoryRequireName then if self.name then local templateName = mw.ustring.match( self.name, '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' ) or self.name templateName = 'Template:' .. templateName self.templateTitle = getTitleObject(templateName) end self.isTemplatePage = self.templateTitle and mw.title.equals(self.title, self.templateTitle) end -- Process data for collapsible text fields. At the moment these are only -- used in {{ambox}}. if self.useCollapsibleTextFields then -- Get the self.issue value. if self.isSmall and args.smalltext then self.issue = args.smalltext else local sect if args.sect == '' then sect = 'This ' .. (cfg.sectionDefault or 'page') elseif type(args.sect) == 'string' then sect = 'This ' .. args.sect end local issue = args.issue issue = type(issue) == 'string' and issue ~= '' and issue or nil local text = args.text text = type(text) == 'string' and text or nil local issues = {} table.insert(issues, sect) table.insert(issues, issue) table.insert(issues, text) self.issue = table.concat(issues, ' ') end -- Get the self.talk value. local talk = args.talk -- Show talk links on the template page or template subpages if the talk -- parameter is blank. if talk == '' and self.templateTitle and ( mw.title.equals(self.templateTitle, self.title) or self.title:isSubpageOf(self.templateTitle) ) then talk = '#' elseif talk == '' then talk = nil end if talk then -- If the talk value is a talk page, make a link to that page. Else -- assume that it's a section heading, and make a link to the talk -- page of the current page with that section heading. local talkTitle = getTitleObject(talk) local talkArgIsTalkPage = true if not talkTitle or not talkTitle.isTalkPage then talkArgIsTalkPage = false talkTitle = getTitleObject( self.title.text, mw.site.namespaces[self.title.namespace].talk.id ) end if talkTitle and talkTitle.exists then local talkText = 'Relevant discussion may be found on' if talkArgIsTalkPage then talkText = string.format( '%s [[%s|%s]].', talkText, talk, talkTitle.prefixedText ) else talkText = string.format( '%s the [[%s#%s|talk page]].', talkText, talkTitle.prefixedText, talk ) end self.talk = talkText end end -- Get other values. self.fix = args.fix ~= '' and args.fix or nil local date if args.date and args.date ~= '' then date = args.date elseif args.date == '' and self.isTemplatePage then date = lang:formatDate('F Y') end if date then self.date = string.format(" <small class='date-container'>''(<span class='date'>%s</span>)''</small>", date) end self.info = args.info if yesno(args.removalnotice) then self.removalNotice = cfg.removalNotice end end -- Set the non-collapsible text field. At the moment this is used by all box -- types other than ambox, and also by ambox when small=yes. if self.isSmall then self.text = args.smalltext or args.text else self.text = args.text end -- Set the below row. self.below = cfg.below and args.below -- General image settings. self.imageCellDiv = not self.isSmall and cfg.imageCellDiv self.imageEmptyCell = cfg.imageEmptyCell if cfg.imageEmptyCellStyle then self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px' end -- Left image settings. local imageLeft = self.isSmall and args.smallimage or args.image if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none' or not cfg.imageCheckBlank and imageLeft ~= 'none' then self.imageLeft = imageLeft if not imageLeft then local imageSize = self.isSmall and (cfg.imageSmallSize or '30x30px') or '40x40px' self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage or 'Information icon4.svg', imageSize) end end -- Right image settings. local imageRight = self.isSmall and args.smallimageright or args.imageright if not (cfg.imageRightNone and imageRight == 'none') then self.imageRight = imageRight end end function MessageBox:setMainspaceCategories() local args = self.args local cfg = self.cfg if not cfg.allowMainspaceCategories then return nil end local nums = {} for _, prefix in ipairs{'cat', 'category', 'all'} do args[prefix .. '1'] = args[prefix] nums = union(nums, getArgNums(args, prefix)) end -- The following is roughly equivalent to the old {{Ambox/category}}. local date = args.date date = type(date) == 'string' and date local preposition = 'from' for _, num in ipairs(nums) do local mainCat = args['cat' .. tostring(num)] or args['category' .. tostring(num)] local allCat = args['all' .. tostring(num)] mainCat = type(mainCat) == 'string' and mainCat allCat = type(allCat) == 'string' and allCat if mainCat and date and date ~= '' then local catTitle = string.format('%s %s %s', mainCat, preposition, date) self:addCat(0, catTitle) catTitle = getTitleObject('Category:' .. catTitle) if not catTitle or not catTitle.exists then self:addCat(0, 'Articles with invalid date parameter in template') end elseif mainCat and (not date or date == '') then self:addCat(0, mainCat) end if allCat then self:addCat(0, allCat) end end end function MessageBox:setTemplateCategories() local args = self.args local cfg = self.cfg -- Add template categories. if cfg.templateCategory then if cfg.templateCategoryRequireName then if self.isTemplatePage then self:addCat(10, cfg.templateCategory) end elseif not self.title.isSubpage then self:addCat(10, cfg.templateCategory) end end -- Add template error categories. if cfg.templateErrorCategory then local templateErrorCategory = cfg.templateErrorCategory local templateCat, templateSort if not self.name and not self.title.isSubpage then templateCat = templateErrorCategory elseif self.isTemplatePage then local paramsToCheck = cfg.templateErrorParamsToCheck or {} local count = 0 for i, param in ipairs(paramsToCheck) do if not args[param] then count = count + 1 end end if count > 0 then templateCat = templateErrorCategory templateSort = tostring(count) end if self.categoryNums and #self.categoryNums > 0 then templateCat = templateErrorCategory templateSort = 'C' end end self:addCat(10, templateCat, templateSort) end end function MessageBox:setAllNamespaceCategories() -- Set categories for all namespaces. if self.isSubstituted then self:addCat('all', 'Pages with incorrectly substituted templates') end end function MessageBox:setCategories() if self.title.namespace == 0 then self:setMainspaceCategories() elseif self.title.namespace == 10 then self:setTemplateCategories() end self:setAllNamespaceCategories() end function MessageBox:renderCategories() if not self.hasCategories then -- No categories added, no need to pass them to Category handler so, -- if it was invoked, it would return the empty string. -- So we shortcut and return the empty string. return "" end -- Convert category tables to strings and pass them through -- [[Module:Category handler]]. return require('Module:Category handler')._main{ main = table.concat(self.categories[0] or {}), template = table.concat(self.categories[10] or {}), all = table.concat(self.categories.all or {}), nocat = self.args.nocat, page = self.args.page } end function MessageBox:export() local root = mw.html.create() -- Add the subst check error. if self.isSubstituted and self.name then root:tag('b') :addClass('error') :wikitext(string.format( 'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.', mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') )) end -- Add TemplateStyles root:wikitext(mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = TEMPLATE_STYLES:format(self.boxType) }, }) -- Create the box table. local boxTable -- Check for fmbox because not all interface messages have mw-parser-output -- which is necessary for TemplateStyles. Add the wrapper class if it is and -- then start the actual mbox, else start the mbox. if self.boxType == 'fmbox' then boxTable = root:tag('div') :addClass('mw-parser-output') :tag('table') else boxTable = root:tag('table') end boxTable:attr('id', self.id or nil) for class, _ in pairs(self.classes or {}) do boxTable:addClass(class or nil) end boxTable :cssText(self.style or nil) :attr('role', 'presentation') if self.attrs then boxTable:attr(self.attrs) end -- Add the left-hand image. local row = boxTable:tag('tr') if self.imageLeft then local imageLeftCell = row:tag('td'):addClass('mbox-image') if self.imageCellDiv then -- If we are using a div, redefine imageLeftCell so that the image -- is inside it. Divs use style="width: 52px;", which limits the -- image width to 52px. If any images in a div are wider than that, -- they may overlap with the text or cause other display problems. imageLeftCell = imageLeftCell:tag('div'):css('width', '52px') end imageLeftCell:wikitext(self.imageLeft or nil) elseif self.imageEmptyCell then -- Some message boxes define an empty cell if no image is specified, and -- some don't. The old template code in templates where empty cells are -- specified gives the following hint: "No image. Cell with some width -- or padding necessary for text cell to have 100% width." row:tag('td') :addClass('mbox-empty-cell') :cssText(self.imageEmptyCellStyle or nil) end -- Add the text. local textCell = row:tag('td'):addClass('mbox-text') if self.useCollapsibleTextFields then -- The message box uses advanced text parameters that allow things to be -- collapsible. At the moment, only ambox uses this. textCell:cssText(self.textstyle or nil) local textCellDiv = textCell:tag('div') textCellDiv :addClass('mbox-text-span') :wikitext(self.issue or nil) if (self.talk or self.fix) and not self.isSmall then textCellDiv:tag('span') :addClass('hide-when-compact') :wikitext(self.talk and (' ' .. self.talk) or nil) :wikitext(self.fix and (' ' .. self.fix) or nil) end textCellDiv:wikitext(self.date and (' ' .. self.date) or nil) if self.info and not self.isSmall then textCellDiv :tag('span') :addClass('hide-when-compact') :wikitext(self.info and (' ' .. self.info) or nil) end if self.removalNotice then textCellDiv:tag('small') :addClass('hide-when-compact') :tag('i') :wikitext(string.format(" (%s)", self.removalNotice)) end else -- Default text formatting - anything goes. textCell :cssText(self.textstyle or nil) :wikitext(self.text or nil) end -- Add the right-hand image. if self.imageRight then local imageRightCell = row:tag('td'):addClass('mbox-imageright') if self.imageCellDiv then -- If we are using a div, redefine imageRightCell so that the image -- is inside it. imageRightCell = imageRightCell:tag('div'):css('width', '52px') end imageRightCell :wikitext(self.imageRight or nil) end -- Add the below row. if self.below then boxTable:tag('tr') :tag('td') :attr('colspan', self.imageRight and '3' or '2') :addClass('mbox-text') :cssText(self.textstyle or nil) :wikitext(self.below or nil) end -- Add error message for invalid type parameters. if self.invalidTypeError then root:tag('div') :css('text-align', 'center') :wikitext(string.format( 'This message box is using an invalid "type=%s" parameter and needs fixing.', self.type or '' )) end -- Add categories. root:wikitext(self:renderCategories() or nil) return tostring(root) end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p, mt = {}, {} function p._exportClasses() -- For testing. return { MessageBox = MessageBox } end function p.main(boxType, args, cfgTables) local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE)) box:setParameters() box:setCategories() return box:export() end function mt.__index(t, k) return function (frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) end end return setmetatable(p, mt) 05da6c4f204e9877c212b3df9fc8bad71389715a Module:Message box/configuration 828 58 129 128 2024-04-03T17:32:21Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Message_box/configuration]] Scribunto text/plain -------------------------------------------------------------------------------- -- Message box configuration -- -- -- -- This module contains configuration data for [[Module:Message box]]. -- -------------------------------------------------------------------------------- return { ambox = { types = { speedy = { class = 'ambox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'ambox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'ambox-content', image = 'Ambox important.svg' }, style = { class = 'ambox-style', image = 'Edit-clear.svg' }, move = { class = 'ambox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'ambox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, notice = { class = 'ambox-notice', image = 'Information icon4.svg' } }, default = 'notice', allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'}, allowSmall = true, smallParam = 'left', smallClass = 'mbox-small-left', substCheck = true, classes = {'metadata', 'ambox'}, imageEmptyCell = true, imageCheckBlank = true, imageSmallSize = '20x20px', imageCellDiv = true, useCollapsibleTextFields = true, imageRightNone = true, sectionDefault = 'article', allowMainspaceCategories = true, templateCategory = 'Article message templates', templateCategoryRequireName = true, templateErrorCategory = 'Article message templates with missing parameters', templateErrorParamsToCheck = {'issue', 'fix', 'subst'}, removalNotice = '<small>[[Help:Maintenance template removal|Learn how and when to remove this template message]]</small>', templatestyles = 'Module:Message box/ambox.css' }, cmbox = { types = { speedy = { class = 'cmbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'cmbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'cmbox-content', image = 'Ambox important.svg' }, style = { class = 'cmbox-style', image = 'Edit-clear.svg' }, move = { class = 'cmbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'cmbox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, notice = { class = 'cmbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'cmbox'}, imageEmptyCell = true, templatestyles = 'Module:Message box/cmbox.css' }, fmbox = { types = { warning = { class = 'fmbox-warning', image = 'Ambox warning pn.svg' }, editnotice = { class = 'fmbox-editnotice', image = 'Information icon4.svg' }, system = { class = 'fmbox-system', image = 'Information icon4.svg' } }, default = 'system', showInvalidTypeError = true, classes = {'fmbox'}, imageEmptyCell = false, imageRightNone = false, templatestyles = 'Module:Message box/fmbox.css' }, imbox = { types = { speedy = { class = 'imbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'imbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'imbox-content', image = 'Ambox important.svg' }, style = { class = 'imbox-style', image = 'Edit-clear.svg' }, move = { class = 'imbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'imbox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, license = { class = 'imbox-license licensetpl', image = 'Imbox-license.svg' }, ["license-related"] = { class = 'imbox-license', image = 'Imbox-license.svg' }, featured = { class = 'imbox-featured', image = 'Cscr-featured.svg', imageNeedsLink = true }, notice = { class = 'imbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'imbox'}, imageEmptyCell = true, below = true, templateCategory = 'File message boxes', templatestyles = 'Module:Message box/imbox.css' }, ombox = { types = { speedy = { class = 'ombox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'ombox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'ombox-content', image = 'Ambox important.svg' }, style = { class = 'ombox-style', image = 'Edit-clear.svg' }, move = { class = 'ombox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'ombox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, notice = { class = 'ombox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'ombox'}, allowSmall = true, imageEmptyCell = true, imageRightNone = true, templatestyles = 'Module:Message box/ombox.css' }, tmbox = { types = { speedy = { class = 'tmbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'tmbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'tmbox-content', image = 'Ambox important.svg' }, style = { class = 'tmbox-style', image = 'Edit-clear.svg' }, move = { class = 'tmbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'tmbox-protection', image = 'Semi-protection-shackle-keyhole.svg' }, notice = { class = 'tmbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'tmbox'}, allowSmall = true, imageRightNone = true, imageEmptyCell = true, templateCategory = 'Talk message boxes', templatestyles = 'Module:Message box/tmbox.css' } } ccb6bdf2868087b6833d203307f2f6a92b3b0a01 Template:Documentation 10 14 131 27 2024-04-03T17:32:23Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Documentation]] wikitext text/x-wiki <noinclude> <languages/> </noinclude><includeonly>{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}</includeonly><noinclude> {{documentation|content= {{Lua|Module:Documentation}} <translate><!--T:12--> This template automatically displays a documentation box like the one you are seeing now, of which the content is sometimes transcluded from another page.</translate> <translate><!--T:13--> It is intended for pages which are [[<tvar name=1>Special:MyLanguage/Help:Transclusion</tvar>|transcluded]] in other pages, i.e. templates, whether in the template namespace or not.</translate> <translate> ==Usage== <!--T:2--> ===Customising display=== <!--T:3--> <!--T:4--> Overrides exist to customise the output in special cases: </translate> * <nowiki>{{</nowiki>documentation{{!}}'''heading'''=<nowiki>}}</nowiki> - <translate><!--T:5--> change the text of the "documentation" heading.</translate> <translate><!--T:10--> If this is set to blank, the entire heading line (including the first [edit] link) will also disappear.</translate> <translate> ==Rationale== <!--T:6--> </translate> <translate><!--T:7--> This template allows any page to use any documentation page, and makes it possible to protect templates while allowing anyone to edit the template's documentation and categories.</translate> <translate><!--T:8--> It also reduces server resources by circumventing a [[w:Wikipedia:Template limits|technical limitation of templates]] (see a [[<tvar name=1>:en:Special:Diff/69888944</tvar>|developer's explanation]]).</translate> <translate> ==See also== <!--T:9--> </translate> * <translate><!--T:14--> [[w:Template:Documentation subpage]]</translate> * {{tim|Documentation}} * <translate><!--T:11--> [[w:Wikipedia:Template documentation]]</translate> }} [[Category:Formatting templates{{#translation:}}|Template documentation]] [[Category:Template documentation{{#translation:}}| ]] </noinclude><includeonly>{{#if:{{{content|}}}| [[Category:Template documentation pages{{#translation:}}]] }}</includeonly> c1ef6cbf9cb4c65ddd087c09aa6affb00dc5bfad Template:Message box/doc 10 59 133 132 2024-04-03T17:32:25Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Message_box/doc]] wikitext text/x-wiki {{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> ==Usage== <syntaxhighlight lang="wikitext">{{Message_box |backgroundcolor = |image = |heading = |message = }} </syntaxhighlight> *'''backgroundcolor''': Box background color (default may depend on skin) *'''image''': Name of image (do not use "Image:" or "File:" heading) *'''heading''': Heading text *'''message''' or '''text''': Message text ==See also== *{{tl|Message}} *{{tl|Mbox}} *[[Message box]] <includeonly>{{sandbox other|| [[Category:Template namespace templates]] [[Category:Wikipedia message box templates| ]] }}</includeonly> 91f7f5df4c8ef4fcec461da62a088d5b7391ce77 Module:Message box/ombox.css 828 60 135 134 2024-04-03T17:32:25Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Message_box/ombox.css]] sanitized-css text/css /* {{pp|small=y}} */ .ombox { margin: 4px 0; border-collapse: collapse; border: 1px solid #a2a9b1; /* Default "notice" gray */ background-color: #f8f9fa; box-sizing: border-box; } /* For the "small=yes" option. */ .ombox.mbox-small { font-size: 88%; line-height: 1.25em; } .ombox-speedy { border: 2px solid #b32424; /* Red */ background-color: #fee7e6; /* Pink */ } .ombox-delete { border: 2px solid #b32424; /* Red */ } .ombox-content { border: 1px solid #f28500; /* Orange */ } .ombox-style { border: 1px solid #fc3; /* Yellow */ } .ombox-move { border: 1px solid #9932cc; /* Purple */ } .ombox-protection { border: 2px solid #a2a9b1; /* Gray-gold */ } .ombox .mbox-text { border: none; /* @noflip */ padding: 0.25em 0.9em; width: 100%; } .ombox .mbox-image { border: none; /* @noflip */ padding: 2px 0 2px 0.9em; text-align: center; } .ombox .mbox-imageright { border: none; /* @noflip */ padding: 2px 0.9em 2px 0; text-align: center; } /* An empty narrow cell */ .ombox .mbox-empty-cell { border: none; padding: 0; width: 1px; } .ombox .mbox-invalid-type { text-align: center; } @media (min-width: 720px) { .ombox { margin: 4px 10%; } .ombox.mbox-small { /* @noflip */ clear: right; /* @noflip */ float: right; /* @noflip */ margin: 4px 0 4px 1em; width: 238px; } } 8fe3df4bb607e699eab2dbd23bd4a1a446391002 R/196 0 22 136 41 2024-04-03T17:32:32Z Nulcow 2 wikitext text/x-wiki {{Template:PTTC|r/196}} {{Template:Stub}} [[File:196home.png|thumb|right|A screenshot of the r/196 index page, as it appeared on April 3rd, 2024]] r/196 is a shitposting subreddit, and the origin of the 196 community that has since spread to other platforms. It's known for the community's anarcho-socialist attitudes and for being a great safe space for queer people. == History == r/196 is the successor to r/195, a similar shitposting subreddit. r/195 slowly grew more corrupt and hateful, so the original admins and community had to put it out of its misery and move on to their new home, r/196. r/196 was also a major part of the various r/place events; even the background image of the subreddit is a screenshot of r/196's section on r/place! d4c8b15b766ae33dc26d9ad8886c2309d9ab12ae Template:Ombox 10 61 139 138 2024-04-03T17:38:00Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Ombox]] wikitext text/x-wiki {{#invoke:Message box|ombox}}<noinclude> {{documentation}} <!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --> </noinclude> 0e54065432d540737b9e56c4e3a8e7f74d4534ea Template:Module other 10 62 141 140 2024-04-03T17:38:02Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Module_other]] wikitext text/x-wiki {{#switch: <!--If no or empty "demospace" parameter then detect namespace--> {{#if:{{{demospace|}}} | {{lc: {{{demospace}}} }} <!--Use lower case "demospace"--> | {{#ifeq:{{NAMESPACE}}|{{ns:Module}} | module | other }} }} | module = {{{1|}}} | other | #default = {{{2|}}} }}<!--End switch--><noinclude> {{documentation}} <!-- Add categories to the /doc subpage, not here! --> </noinclude> 503694836c1b07142e63fd35d8be69ec8bb9ffe7 Template:Module rating 10 63 143 142 2024-04-03T17:38:03Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Module_rating]] wikitext text/x-wiki <includeonly>{{#ifeq:{{SUBPAGENAME}}|doc|<!--do not show protection level of the module on the doc page, use the second and optionally third parameter if the doc page is also protected -->{{#if:{{{2|}}}|{{Pp|{{{2}}}|action={{{3|}}}}}}}|{{Module other|{{ombox | type = notice | image = {{#switch: {{{1|}}} | pre-alpha | prealpha | pa = [[File:Ambox warning blue construction.svg|40x40px|link=|alt=Pre-alpha]] | alpha | a = [[File:Greek lc alpha icon.svg|26x26px|link=|alt=Alpha]] | beta | b = [[File:Greek lc beta icon.svg|40x40px|link=|alt=Beta]] | release | r | general | g = [[File:Green check.svg|40x40px|link=|alt=Ready for use]] | protected | protect | p = [[File:{{#switch:{{#invoke:Effective protection level|edit|{{#switch:{{SUBPAGENAME}}|doc|sandbox={{FULLBASEPAGENAME}}|{{FULLPAGENAME}}}}}}|autoconfirmed=Semi|extendedconfirmed=Extended|accountcreator|templateeditor=Template|#default=Full}}-protection-shackle.svg|40x40px|link=|alt=Protected]] | semiprotected | semiprotect | semi =[[File:Semi-protection-shackle.svg|40x40px|link=|alt=Semi-protected]] }} | style = | textstyle = | text = {{#switch: {{{1|}}} | pre-alpha | prealpha | pa = This module is rated as [[:Category:Modules in pre-alpha development|pre-alpha]]. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. | alpha | a = This module is rated as [[:Category:Modules in alpha|alpha]]. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. | beta | b = This module is rated as [[:Category:Modules in beta|beta]], and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. | release | r | general | g = This module is rated as [[:Category:Modules for general use|ready for general use]]. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by [[Wikipedia:Template sandbox and test cases|sandbox testing]] rather than repeated trial-and-error editing. | protected | protect | p = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[Wikipedia:Protection policy|protected]] from editing. | semiprotected | semiprotect | semi = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[WP:SEMI|semi-protected]] from editing. | #default = {{error|Module rating is invalid or not specified.}} }} }}<!-- -->{{#ifeq: {{ROOTPAGENAME}} | Sandbox | <!-- No category for user sandboxes --> | {{#switch: {{SUBPAGENAME}} | doc | sandbox =<!-- No category for /doc or /sandbox subpages --> | {{#ifeq: {{{nocat|}}} | true | <!-- No category if user sets nocat=true --> | {{#switch: {{{1|}}} | pre-alpha | prealpha | pa = [[Category:Modules in pre-alpha development|{{PAGENAME}}]] | alpha | a = [[Category:Modules in alpha|{{PAGENAME}}]] | beta | b = [[Category:Modules in beta|{{PAGENAME}}]] | release | r | general | g = [[Category:Modules for general use|{{PAGENAME}}]] | protected | protect | p = [[Category:Modules subject to page protection|{{PAGENAME}}]] | semiprotected | semiprotect | semi = [[Category:Modules subject to page protection|{{PAGENAME}}]] }} }} }} }}<!-- -->|{{error|Error: {{tl|Module rating}} must be placed in the Module namespace.}} [[Category:Pages with templates in the wrong namespace]]|demospace={{{demospace|<noinclude>module</noinclude>}}}}}}}<!-- --></includeonly><noinclude> {{module rating|release|nocat=true|demospace=module}} {{documentation}} <!-- Categories go on the /doc subpage, and interwikis go in Wikidata. --> </noinclude> 75c928c417eb4da2a338898531fd8d501e05adbb Module:Transclusion count/data/M 828 64 145 144 2024-04-03T17:38:03Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Transclusion_count/data/M]] Scribunto text/plain return { ["M"] = 2100, ["MAD"] = 2100, ["MAR"] = 2900, ["MAS"] = 2600, ["MDG"] = 2400, ["MEX"] = 6300, ["MILHIST"] = 5100, ["MINUTE"] = 2300, ["MKD"] = 2400, ["MLB_Farm_System"] = 2100, ["MLB_Year"] = 15000, ["MLB_standings"] = 3800, ["MLBplayer"] = 4000, ["MMA_record_start"] = 3700, ["MMArecordbox"] = 3700, ["MMSI_Number"] = 3200, ["MONTH"] = 13000, ["MONTHNAME"] = 859000, ["MONTHNUMBER"] = 873000, ["MS"] = 5400, ["MV"] = 9200, ["MYS"] = 3800, ["MacTutor"] = 2000, ["Main"] = 351000, ["Main_article"] = 31000, ["Main_other"] = 9780000, ["Main_page_image"] = 27000, ["Main_page_image/DYK"] = 11000, ["Main_page_image/ITN/styles.css"] = 2900, ["Main_page_image/TFA"] = 5000, ["Maintenance_category"] = 39000, ["Malay_name"] = 2500, ["Map_requested"] = 6400, ["Map_requested/Category_helper"] = 6300, ["Maplink"] = 37000, ["Maplink-road"] = 6200, ["Marriage"] = 78000, ["Marriage/doc"] = 78000, ["Marriage/styles.css"] = 78000, ["Math"] = 10000, ["MathGenealogy"] = 7200, ["MathWorld"] = 2400, ["Mathgenealogy"] = 2200, ["Max"] = 239000, ["Maybe_free_media"] = 12000, ["Mbox"] = 3190000, ["Mdash"] = 9200, ["MeSH_name"] = 6000, ["Medal"] = 118000, ["MedalBottom"] = 16000, ["MedalBronze"] = 56000, ["MedalComp"] = 2300, ["MedalCompetition"] = 91000, ["MedalCount"] = 3400, ["MedalCountry"] = 81000, ["MedalGold"] = 55000, ["MedalOlympic"] = 4000, ["MedalOlympics"] = 6100, ["MedalSilver"] = 54000, ["MedalSport"] = 80000, ["MedalTableTop"] = 17000, ["MedalTop"] = 3800, ["MedalWorldChampionships"] = 2000, ["MedalistTable"] = 15000, ["Medals_table"] = 15000, ["Media"] = 2600, ["Medical_resources"] = 6900, ["Merge_done"] = 3800, ["Merge_partner"] = 2100, ["Merged-from"] = 17000, ["Merged-to"] = 19000, ["Merged_to"] = 2200, ["MeshName"] = 5900, ["Metacritic_film"] = 4000, ["Metadata_Population_DE-BY"] = 2100, ["Metadata_Population_DE-RP"] = 2300, ["Mhof"] = 7500, ["Mid-Class"] = 15000, ["Mid-importance"] = 15000, ["Middot"] = 6200, ["Midsize"] = 2300, ["MilHist"] = 2700, ["Military_navigation"] = 65000, ["Min"] = 29000, ["Minor_planet"] = 5200, ["Minor_planet_link"] = 2600, ["Minor_planet_list_link"] = 4200, ["Minor_planets_navigator"] = 3200, ["MirrorH"] = 6100, ["Missing_information"] = 3800, ["Mlby"] = 15000, ["Mobile_IP"] = 8500, ["MobyGames"] = 9000, ["Moby_game"] = 7100, ["Mod"] = 7600, ["Module_other"] = 3600, ["Mojo_title"] = 7800, ["Molecular_formula_index"] = 2300, ["Monday"] = 2700, ["Mono"] = 30000, ["Mono/styles.css"] = 31000, ["MonthCategoryNav"] = 36000, ["MonthlyArchive"] = 3700, ["MonthlyLinks"] = 3800, ["Monthly_archive_list"] = 3800, ["Monthly_clean-up_category"] = 16000, ["Monthly_clean-up_category/core"] = 16000, ["Monthly_clean-up_category/monthname"] = 17000, ["Monthly_clean-up_category/monthno"] = 17000, ["Monthly_clean-up_category/name_part"] = 17000, ["Monthly_clean-up_category/outer_core"] = 16000, ["Monthly_clean-up_category/to_add"] = 2900, ["Monthly_clean_up_category"] = 6900, ["Monthyear"] = 64000, ["Monthyear-1"] = 62000, ["MoreInfo"] = 2100, ["More_citations_needed"] = 380000, ["More_citations_needed_section"] = 16000, ["More_footnotes"] = 33000, ["More_footnotes_needed"] = 54000, ["More_plot"] = 3200, ["More_references"] = 3200, ["Moresources"] = 6000, ["Motorcycle_Hall_of_Fame"] = 7500, ["Motorsport_season"] = 5000, ["Motorsport_season/styles.css"] = 5000, ["Moved_discussion_from"] = 3000, ["Moved_discussion_to"] = 2700, ["Mp"] = 5100, ["Mpl"] = 2600, ["MultiReplace"] = 216000, ["Multiple_image"] = 54000, ["Multiple_image/styles.css"] = 54000, ["Multiple_issues"] = 123000, ["Multiple_issues/styles.css"] = 123000, ["Music"] = 7700, ["MusicBrainz_artist"] = 2300, ["MusicBrainz_meta"] = 5400, ["MusicBrainz_release_group"] = 2300, ["Music_ratings"] = 97000, ["Mvar"] = 8100, ["Mw_lang"] = 83000, ["My"] = 2500, ["My_sandbox"] = 3900, ["Myprefs"] = 11000, ["Module:MLB_standings"] = 3800, ["Module:MLB_standings/data"] = 3800, ["Module:Main_page_image"] = 16000, ["Module:Mapframe"] = 455000, ["Module:Math"] = 1590000, ["Module:Medals_table"] = 15000, ["Module:Message_box"] = 18600000, ["Module:Message_box/ambox.css"] = 3230000, ["Module:Message_box/cmbox.css"] = 433000, ["Module:Message_box/configuration"] = 9910000, ["Module:Message_box/fmbox.css"] = 20000, ["Module:Message_box/imbox.css"] = 933000, ["Module:Message_box/ombox.css"] = 1660000, ["Module:Message_box/tmbox.css"] = 12700000, ["Module:Military_navigation"] = 85000, ["Module:Minor_planet_list_link"] = 4200, ["Module:MultiReplace"] = 1290000, ["Module:Multiple_image"] = 54000, ["Module:Music_ratings"] = 97000, ["Module:Mw_lang"] = 83000, } d97f689b81758a648cecd4297ecc6a711751a277 Template:Used in system 10 65 147 146 2024-04-03T17:38:04Z Nulcow 2 1 revision imported from [[:wikipedia:Template:Used_in_system]] wikitext text/x-wiki {{#invoke:High-use|main|1=|2={{{2|}}}|system={{#if:{{{1|}}}|{{{1}}}|in system messages}}<noinclude>|nocat=true</noinclude>}}<noinclude> {{documentation}}<!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 0abe278369db6cbbe319e7452d7644e27e11c532 Module:Message box/configuration/doc 828 66 149 148 2024-04-03T17:38:04Z Nulcow 2 1 revision imported from [[:wikipedia:Module:Message_box/configuration/doc]] wikitext text/x-wiki {{Used in system}} {{Module rating|protected}} Configuration for [[Module:Message box]]. ffb793a2e927e8589f3a9b2cc287b2d4584e7afb Template:Stub 10 25 150 53 2024-04-03T17:40:47Z Nulcow 2 wikitext text/x-wiki <!--{{asbox | image = | pix = | subject = | article = article | qualifier = | category = Stubs | tempsort = no | lowercase = y | name = Template:Stub }}--> This article is a stub. That means it's damn short, yo! You should probably go do something about it. f4f4c8bdeb9696accbe24af6727136c025ab9191 Template:Stub 10 25 151 150 2024-04-03T17:41:09Z Nulcow 2 wikitext text/x-wiki <!--{{asbox | image = | pix = | subject = | article = article | qualifier = | category = Stubs | tempsort = no | lowercase = y | name = Template:Stub }}--> ''This article is a stub. That means it's damn short, yo! You should probably go do something about it.'' fbf9c28ab7d720dcb6595ab89fc486914bc455f1 File:Spronkus origin.png 6 67 152 2024-04-03T17:55:17Z Nulcow 2 wikitext text/x-wiki The image Spronkus Kronkus originates from 096bb7fe454f769bec2c76a79e3d68319074f855 File:Spronkus place.jpg 6 68 153 2024-04-03T17:58:51Z Nulcow 2 wikitext text/x-wiki Screenshot of the r/place canvas featuring Spronkus 83f1988033d2693140a030981c0fafb1ec06aacf Spronkus Kronkus 0 69 154 2024-04-03T18:02:11Z Nulcow 2 Created page with "[[File:Spronkus place.jpg|thumb|right|Spronkus on the r/place canvas]] '''Spronkus Kronkus''' is a bright yellow rabbit with a face resembling a [[&#58;3]] on meth. Their face is used as this wiki's logo, and they are generally known as the "mascot" of 196. == Origin == [[File:Spronkus origin.png|thumb|right|The first image of Spronkus]] Spronkus originates from a crude drawing, first linked to on r/196 on December 13th, 2021." wikitext text/x-wiki [[File:Spronkus place.jpg|thumb|right|Spronkus on the r/place canvas]] '''Spronkus Kronkus''' is a bright yellow rabbit with a face resembling a [[&#58;3]] on meth. Their face is used as this wiki's logo, and they are generally known as the "mascot" of 196. == Origin == [[File:Spronkus origin.png|thumb|right|The first image of Spronkus]] Spronkus originates from a crude drawing, first linked to on r/196 on December 13th, 2021. b82a0e4b9ec35677e60f072efb79454f2413cf6f 159 154 2024-04-03T18:25:45Z Nulcow 2 wikitext text/x-wiki [[File:Spronkus place.jpg|thumb|right|Spronkus on the r/place canvas]] '''Spronkus Kronkus''' is a bright yellow rabbit with a face resembling a [[&#58;3]] on meth. Their face is used as this wiki's logo, and they are generally known as the "mascot" of 196. == Origin == [[File:Spronkus origin.png|thumb|right|The first image of Spronkus]] Spronkus originates from a crude drawing, first linked to on r/196 on December 13th, 2021 by the Redditor {{Redditor|not_a_stick}}. The image depicts Spronkus under the label "Leftist shitposting", saying "I am a recogniseable cartoon charachter i say trans rights and shoot fascists", holding a trans flag and a gun labeled "this is a gun". The character quickly caught on among 196ers. Since then, many people would post artwork of Spronkus, who still retained most of their original identity. == Characteristics == Spronkus is a rabbit with bright yellow fur, solid, vertical ears, and a round-rectangle head. They are known to carry a gun, a trans flag, and an axe with trans flag colours. The text "this is a gun" is usually superimposed over the gun, like in the original artwork. Spronkus is canonically genderfluid, alternating between masculine and feminine with combined masculine and feminine characteristics, usually determined by the artist. == Relationships == [[File:Floppa.webp|thumb|right|A photograph of Big Floppa]] Spronkus's boyfriend is [[Big Floppa]], a large caracal. He is usually depicted alongside Spronkus in artwork. 9faa1b46ee2757ff085b5281d304f9e3aa7c3c5a 163 159 2024-04-04T14:38:14Z Nulcow 2 wikitext text/x-wiki [[File:Spronkus place.jpg|thumb|right|Spronkus on the r/place canvas]] '''Spronkus Kronkus''' is a bright yellow rabbit with a face resembling a [[&#58;3]] on either weed or meth, depending on the situation. Their face is used as this wiki's logo, and they are generally known as the "mascot" of 196. == Origin == [[File:Spronkus origin.png|thumb|right|The first image of Spronkus]] Spronkus originates from a crude drawing, first linked to on r/196 on December 13th, 2021 by the Redditor {{Redditor|not_a_stick}}. The image depicts Spronkus under the label "Leftist shitposting", saying "I am a recogniseable cartoon charachter i say trans rights and shoot fascists", holding a trans flag and a gun labeled "this is a gun". The character quickly caught on among 196ers. Since then, many people would post artwork of Spronkus, who still retained most of their original identity. == Characteristics == Spronkus is a rabbit with bright yellow fur, solid, vertical ears, and a round-rectangle head. They are known to carry a gun, a trans flag, and an axe with trans flag colours. The text "this is a gun" is usually superimposed over the gun, like in the original artwork. Spronkus is canonically genderfluid, alternating between masculine and feminine with combined masculine and feminine characteristics, usually determined by the artist. == Relationships == [[File:Floppa.webp|thumb|right|A photograph of Big Floppa]] Spronkus's boyfriend is [[Big Floppa]], a large caracal. He is usually depicted alongside Spronkus in artwork. 076214642e7ce4387a088eac66638b0df21cec03 Main Page 0 1 155 43 2024-04-03T18:06:36Z Nulcow 2 wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px; padding-bottom: 0; width: 100%;"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> <center> Rulepedia is the 196 encyclopedia that anyone can edit. We currently have {{NUMBEROFARTICLES}} articles, and people like you are adding more every day! [ [[Rulepedia:About|Learn more]] ] </td> </center> </tr> </table> <br> <table style="background-color: #ffeeee; border: 1px solid #ddcccc; float: left; width: calc(50% - 8px); margin-right: 8px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #ddcccc;">Featured</th> </tr> <tr> <td>{{#ifexpr:{{formatnum:{{PAGESIZE:Rulepedia:Featured Article/{{#time:F j, Y}}}}|R}}>150|{{Rulepedia:Featured Article/{{#time:F j, Y}}}}|{{Rulepedia:Featured Article/{{#time:F j, Y|-1 day}}}}}}</td> </tr> <tr> <th style="border-bottom: 1px solid #ddcccc;">What's new</th> </tr> <tr> <td> ''Coming soon...'' </td> </tr> </table> <table style="background-color: #ddeeff; border: 1px solid #bbccdd; float: right; width: calc(50% - 4px); margin-left: 4px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #bbccdd;">Articles of Awesome</th> </tr> <tr> <td> These are articles which are high-quality and/or about important 196-related topics. If there's an important topic here that doesn't have an article, write one for it! * [[r/196]], the 196 subreddit * [[Spronkus Kronkus]], the recognisable cartoon character who says "trans rights" and shoots fascists * [[Rule]], the one rule of r/196 * [[Big Floppa]], great kitby, partner of Spronkus * [[List of 196 phenomena]] * [[List of notable 196ers]] </td> </tr> <tr> <th style="border-bottom: 1px solid #bbccdd;">More 196</th> </tr> <tr> <td> Looking for places to chat and shitpost with other 196ers? We've got you covered! * {{Subreddit|196}} (subreddit) * [https://www.tumblr.com/tagged/196 #196 on Tumblr] * [https://cohost.org/rc/tagged/196 #196 on Cohost] </td> </tr> </table> 51985189319f0b86e96445f2877324a94f41c168 160 155 2024-04-03T18:27:34Z Nulcow 2 Protected "[[Main Page]]": High traffic page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) wikitext text/x-wiki __NOTOC__ <table style="background-color: #00000008; border: 1px solid #0004; padding: 12px; padding-bottom: 0; width: 100%;"> <tr> <th style="font-size: 1.375rem;">Welcome to {{SITENAME}}!</th> </tr> <tr> <td> <center> Rulepedia is the 196 encyclopedia that anyone can edit. We currently have {{NUMBEROFARTICLES}} articles, and people like you are adding more every day! [ [[Rulepedia:About|Learn more]] ] </td> </center> </tr> </table> <br> <table style="background-color: #ffeeee; border: 1px solid #ddcccc; float: left; width: calc(50% - 8px); margin-right: 8px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #ddcccc;">Featured</th> </tr> <tr> <td>{{#ifexpr:{{formatnum:{{PAGESIZE:Rulepedia:Featured Article/{{#time:F j, Y}}}}|R}}>150|{{Rulepedia:Featured Article/{{#time:F j, Y}}}}|{{Rulepedia:Featured Article/{{#time:F j, Y|-1 day}}}}}}</td> </tr> <tr> <th style="border-bottom: 1px solid #ddcccc;">What's new</th> </tr> <tr> <td> ''Coming soon...'' </td> </tr> </table> <table style="background-color: #ddeeff; border: 1px solid #bbccdd; float: right; width: calc(50% - 4px); margin-left: 4px; padding: 8px;"> <tr> <th style="border-bottom: 1px solid #bbccdd;">Articles of Awesome</th> </tr> <tr> <td> These are articles which are high-quality and/or about important 196-related topics. If there's an important topic here that doesn't have an article, write one for it! * [[r/196]], the 196 subreddit * [[Spronkus Kronkus]], the recognisable cartoon character who says "trans rights" and shoots fascists * [[Rule]], the one rule of r/196 * [[Big Floppa]], great kitby, partner of Spronkus * [[List of 196 phenomena]] * [[List of notable 196ers]] </td> </tr> <tr> <th style="border-bottom: 1px solid #bbccdd;">More 196</th> </tr> <tr> <td> Looking for places to chat and shitpost with other 196ers? We've got you covered! * {{Subreddit|196}} (subreddit) * [https://www.tumblr.com/tagged/196 #196 on Tumblr] * [https://cohost.org/rc/tagged/196 #196 on Cohost] </td> </tr> </table> 51985189319f0b86e96445f2877324a94f41c168 R/196 0 22 156 136 2024-04-03T18:07:16Z Nulcow 2 wikitext text/x-wiki {{Template:PTTC|r/196}} {{Template:Stub}} [[File:196home.png|thumb|right|A screenshot of the r/196 index page, as it appeared on April 3rd, 2024]] r/196, also called the "Apartment of Awesome", is a shitposting subreddit, and the origin of the 196 community that has since spread to other platforms. It's known for the community's anarcho-socialist attitudes and for being a great safe space for queer people. == History == r/196 is the successor to r/195, a similar shitposting subreddit. r/195 slowly grew more corrupt and hateful, so the original admins and community had to put it out of its misery and move on to their new home, r/196. r/196 was also a major part of the various r/place events; even the background image of the subreddit is a screenshot of r/196's section on r/place! a9d310981efc962c7def32a0a5ccd1373bf94877 Template:Redditor 10 70 157 2024-04-03T18:09:41Z Nulcow 2 Created page with "[https://www.reddit.com/u/{{{1|asynkitty}}} u/{{{1|asynkitty}}}]" wikitext text/x-wiki [https://www.reddit.com/u/{{{1|asynkitty}}} u/{{{1|asynkitty}}}] 359dceb7a889868c194d7bd284f189dd498b58d9 File:Floppa.webp 6 71 158 2024-04-03T18:24:24Z Nulcow 2 wikitext text/x-wiki A photograph of Big Floppa 5a8b9020d8dc5ed3760fa0e84f213f4209e51539 MediaWiki:Monobook.css 8 6 161 31 2024-04-03T19:15:15Z Nulcow 2 css text/css body, body.skin--responsive { background: /*url("https://styles.redditmedia.com/t5_2v92f/styles/bannerBackgroundImage_bzjo1qztep091.png?width=4000&s=c01c5a9c988b813df8a3063d16f7da5e9eba80d2"), */url("https://b.thumbs.redditmedia.com/nOCyGNiEUU5EnNAizm5mZzWxB3V-FBch2R5i2bFBG-Q.png"), #cee3f8; background-repeat: /*no-repeat, */no-repeat, repeat; background-attachment: /*scroll, fixed, */fixed; background-size: /*calc(100% + 1384px) auto, */auto, auto; background-position: top right, top left; /*background-position: left -500px top 0, top left, top left;*/ font-family: Verdana, Tahoma, sans-serif; } .mw-body, body.skin--responsive .mw-body { min-height: 100%; border: 1px solid #5f99cf; } .mw-footer { margin-bottom: 0; padding: 8px 0; border-bottom: none; border-top-color: #5f99cf; } .pBody, body.skin--responsive .pBody, .mw-portlet > div, body.skin--responsive .mw-portlet > div { border: 1px solid #5f99cf; /*border-left: none; border-right: none; border-bottom: none;*/ } .mw-portlet > div, body.skin--responsive .mw-portlet > div, .pBody, body.skin--responsive .pBody { margin-left: 8px; } .mw-portlet label, body.skin--responsive .mw-portlet label, .portlet h3, body.skin--responsive .portlet h3 { margin-left: 2px; } #p-cations li, body.skin--responsive #p-cactions li { padding: 2px 0 1em 0; border: none; } #p-cations li.selected, body.skin--responsive #p-cactions li.selected { border: 1px solid #5f99cf; } #p-cations li a, body.skin--responsive #p-cactions li a { padding: 2px 6px 3px 6px; background: #EFF7FF; } #p-personal, body.skin--responsive #p-personal { top: calc(1.3em - 1px); right: 0; left: unset; max-width: max-content; } #p-personal ul, body.skin--responsive #p-personal ul { background-color: #EFF7FF; height: 20px; padding: 4px; /*padding-bottom: 0;*/ border-top-left-radius: 7px; line-height: 12px; } #p-personal li, body.skin--responsive #p-personal li { display: inline-block; position: relative; bottom: 2px; margin-left: 0; } #p-personal li::after, body.skin--responsive #p-personal li::after { content: '|'; margin: 0 4px; color: grey; } /*#column-content, body.skin--responsive #column-content { min-height: 100%; } #column-one, body.skin--responsive #column-one { width: 12.2em; min-height: max-content; } #sidebar { background: #ffffff; height: 100%; padding-top: 0.5em; border: 1px solid #5f99cf; border-left: none; border-right: none; }*/ #pt-notifications-alert .mw-echo-notifications-badge, #pt-notifications-notice .mw-echo-notifications-badge { width: 15px; height: 15px; } #pt-notifications-notice .mw-echo-notifications-badge, #pt-notifications-alert .mw-echo-notifications-badge { background-size: 15px 15px; top: 0; } fa6b7291303e41cab882c2f6c1f13a35c1050d7e Rulepedia:Featured Article/April 3, 2024 4 72 162 2024-04-04T13:14:52Z Nulcow 2 Created page with "{{Feature|Spronkus Kronkus}}" wikitext text/x-wiki {{Feature|Spronkus Kronkus}} af2106fa77a57e42c16a998250cb2b94876904b4 Rulepedia:Featured Article/April 4, 2024 4 73 164 2024-04-05T14:25:02Z Nulcow 2 Created page with "{{Feature|R/196}}" wikitext text/x-wiki {{Feature|R/196}} b082a29832eacec6e2235af5aa20ec7fdb1ee67d MediaWiki:Sidebar 8 74 165 2024-04-05T19:17:08Z Nulcow 2 Created page with " * navigation ** mainpage|mainpage-description ** recentchanges-url|recentchanges ** randompage-url|randompage <!--** helppage|help-mediawiki--> * 196 ** {{Subreddit|196}} ** [https://www.tumblr.com/tagged/196 #196 on Tumblr] ** [https://cohost.org/rc/tagged/196 #196 on Cohost] * SEARCH * TOOLBOX * LANGUAGES" wikitext text/x-wiki * navigation ** mainpage|mainpage-description ** recentchanges-url|recentchanges ** randompage-url|randompage <!--** helppage|help-mediawiki--> * 196 ** {{Subreddit|196}} ** [https://www.tumblr.com/tagged/196 #196 on Tumblr] ** [https://cohost.org/rc/tagged/196 #196 on Cohost] * SEARCH * TOOLBOX * LANGUAGES f389fc76fb571972ed9f54e7e2db94bc9a952f30 166 165 2024-04-05T19:18:38Z Nulcow 2 wikitext text/x-wiki * navigation ** mainpage|mainpage-description ** recentchanges-url|recentchanges ** randompage-url|randompage <!--** helppage|help-mediawiki--> * 196 ** https://www.reddit.com/r/196|r/196 subreddit ** https://www.tumblr.com/tagged/196|#196 on Tumblr ** https://cohost.org/rc/tagged/196|#196 on Cohost * SEARCH * TOOLBOX * LANGUAGES 1030fc91ae9fb0c3bd2f7eb7d2236be4ea524f8a Rulepedia:Featured Article/April 8, 2024 4 75 167 2024-04-09T15:30:43Z Nulcow 2 Created page with "{{Feature|Spronkus Kronkus}}" wikitext text/x-wiki {{Feature|Spronkus Kronkus}} af2106fa77a57e42c16a998250cb2b94876904b4 Rule 0 76 168 2024-04-09T15:33:50Z Nulcow 2 Created page with "{{Stub}} '''Rule''' refers to the 1 rule of [[r/196]]: if you visit, you must post at least once before you leave. This rule ensures that as long as r/196 has new visitors, it will have new content; this also discourages lurking and other behaviour which may be harmful to the subreddit's growth. In addition, it also creates a strong sense of community within r/196." wikitext text/x-wiki {{Stub}} '''Rule''' refers to the 1 rule of [[r/196]]: if you visit, you must post at least once before you leave. This rule ensures that as long as r/196 has new visitors, it will have new content; this also discourages lurking and other behaviour which may be harmful to the subreddit's growth. In addition, it also creates a strong sense of community within r/196. a8738e3f643e710d97845dd5cf2de7fb831e2854 Big Floppa 0 77 169 2024-04-09T15:47:14Z Nulcow 2 Created page with "'''Big Floppa''' is a large, brown caracal cat with big floppy ears, who is considered to be the husband of [[Spronkus Kronkus]]. He has comparatively minimal involvement in r/196, but he is still an important and notable character nonetheless. He is a powerful gang leader, and his greatest enemy is Sogga. == History == Not much is known about Big Floppa's history. He allegedly keeps his past a secret because of his tendency to engage in criminal activity. His original..." wikitext text/x-wiki '''Big Floppa''' is a large, brown caracal cat with big floppy ears, who is considered to be the husband of [[Spronkus Kronkus]]. He has comparatively minimal involvement in r/196, but he is still an important and notable character nonetheless. He is a powerful gang leader, and his greatest enemy is Sogga. == History == Not much is known about Big Floppa's history. He allegedly keeps his past a secret because of his tendency to engage in criminal activity. His original name was Gregory, but he earned the name Big Floppa for his big ears and large size. After some time, Big Floppa grew to become a notorious gangster, leading one of the most powerful gangs in the world. == Appearance == Big Floppa has brown fur with dark brown markings, large ears with tufts of fur on the end, and is generally very large. He is a caracal, a species of wild cat. == Relationships == Big Floppa is the husband of Spronkus Kronkus, but most of the details of their relationship are private. However, it's widely known that his greatest enemy is Sogga and his gang. 5ba60bfd2f36c7e46fbb6c59ba745db873f0c0b4 170 169 2024-04-09T15:48:44Z Nulcow 2 wikitext text/x-wiki [[File:Floppa.webp|thumb|Big Floppa in one of his iconic photos]] '''Big Floppa''' is a large, brown caracal cat with big floppy ears, who is considered to be the husband of [[Spronkus Kronkus]]. He has comparatively minimal involvement in r/196, but he is still an important and notable character nonetheless. He is a powerful gang leader, and his greatest enemy is Sogga. == History == Not much is known about Big Floppa's history. He allegedly keeps his past a secret because of his tendency to engage in criminal activity. His original name was Gregory, but he earned the name Big Floppa for his big ears and large size. After some time, Big Floppa grew to become a notorious gangster, leading one of the most powerful gangs in the world. == Appearance == Big Floppa has brown fur with dark brown markings, large ears with tufts of fur on the end, and is generally very large. He is a caracal, a species of wild cat. == Relationships == Big Floppa is the husband of Spronkus Kronkus, but most of the details of their relationship are private. However, it's widely known that his greatest enemy is Sogga and his gang. 1317a42344e786313cec9ce034314a942b986afa Rulepedia:Featured Article/April 9, 2024 4 78 171 2024-04-10T13:55:52Z Nulcow 2 Created page with "{{Feature|Big Floppa}}" wikitext text/x-wiki {{Feature|Big Floppa}} ac9195e8c2de20b64246e4015f4f22929a37c7d6